tint: const eval of fract
Bug: tint:1581
Change-Id: I14207080b14e45e7520f50230c85cd902f25dc71
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113943
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 3a2219a..db2dd09 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -494,8 +494,8 @@
@const fn floor<N: num, T: fa_f32_f16>(@test_value(1.5) vec<N, T>) -> vec<N, T>
@const fn fma<T: fa_f32_f16>(T, T, T) -> T
@const fn fma<N: num, T: fa_f32_f16>(vec<N, T>, vec<N, T>, vec<N, T>) -> vec<N, T>
-fn fract<T: f32_f16>(T) -> T
-fn fract<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
+@const fn fract<T: fa_f32_f16>(@test_value(1.25) T) -> T
+@const fn fract<N: num, T: fa_f32_f16>(@test_value(1.25) vec<N, T>) -> vec<N, T>
@const fn frexp<T: fa_f32_f16>(T) -> __frexp_result<T>
@const fn frexp<N: num, T: fa_f32_f16>(vec<N, T>) -> __frexp_result_vec<N, T>
@stage("fragment") fn fwidth(f32) -> f32
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 115082c..5d13abf 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -2680,6 +2680,20 @@
return TransformElements(builder, ty, transform, args[0], args[1], args[2]);
}
+ConstEval::Result ConstEval::fract(const type::Type* ty,
+ utils::VectorRef<const constant::Constant*> args,
+ const Source& source) {
+ auto transform = [&](const constant::Constant* c1) {
+ auto create = [&](auto e) -> ImplResult {
+ using NumberT = decltype(e);
+ auto r = e - std::floor(e);
+ return CreateElement(builder, source, c1->Type(), NumberT{r});
+ };
+ return Dispatch_fa_f32_f16(create, c1);
+ };
+ return TransformElements(builder, ty, transform, args[0]);
+}
+
ConstEval::Result ConstEval::frexp(const type::Type* ty,
utils::VectorRef<const constant::Constant*> args,
const Source& source) {
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index 20b5e77..6caac07 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -689,6 +689,15 @@
utils::VectorRef<const constant::Constant*> args,
const Source& source);
+ /// fract builtin
+ /// @param ty the expression type
+ /// @param args the input arguments
+ /// @param source the source location
+ /// @return the result value, or null if the value cannot be calculated
+ Result fract(const type::Type* ty,
+ utils::VectorRef<const constant::Constant*> args,
+ const Source& source);
+
/// frexp 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 82c6d38..25adcef 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -1173,6 +1173,38 @@
FmaCases<f16>()))));
template <typename T>
+std::vector<Case> FractCases() {
+ auto r = std::vector<Case>{
+ C({T(0)}, T(0)),
+ C({T(0.1)}, T(0.1)),
+ C({T(-0.1)}, T(0.9)),
+ C({T(0.0000001)}, T(0.0000001)),
+ C({T(-0.0000001)}, T(0.9999999)),
+ C({T(12.34567)}, T(0.34567)).FloatComp(0.002),
+ C({T(-12.34567)}, T(0.65433)).FloatComp(0.002),
+ C({T::Lowest()}, T(0)),
+ C({T::Highest()}, T(0)),
+ // Vector tests
+ C({Vec(T(0.1), T(-0.1), T(-0.0000001))}, Vec(T(0.1), T(0.9), T(0.9999999))),
+ };
+ // Note: Valid results are in the closed interval [0, 1.0]. For example, if e is a very small
+ // negative number, then fract(e) may be 1.0.
+ ConcatIntoIf<!std::is_same_v<T, f16>>( //
+ r, std::vector<Case>{
+ C({T(-0.000000000000000001)}, T(1)),
+ });
+
+ return r;
+}
+INSTANTIATE_TEST_SUITE_P( //
+ Fract,
+ ResolverConstEvalBuiltinTest,
+ testing::Combine(testing::Values(sem::BuiltinType::kFract),
+ testing::ValuesIn(Concat(FractCases<AFloat>(), //
+ FractCases<f32>(),
+ FractCases<f16>()))));
+
+template <typename T>
std::vector<Case> FrexpCases() {
using F = T; // fract type
using E = std::conditional_t<std::is_same_v<T, AFloat>, AInt, i32>; // exp type
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index fd2822b..926f6b5 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -12461,24 +12461,24 @@
/* 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[856],
/* return matcher indices */ &kMatcherIndices[3],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::fract,
},
{
/* [348] */
/* 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[857],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::fract,
},
{
/* [349] */
@@ -14203,8 +14203,8 @@
},
{
/* [39] */
- /* fn fract<T : f32_f16>(T) -> T */
- /* fn fract<N : num, T : f32_f16>(vec<N, T>) -> vec<N, T> */
+ /* fn fract<T : fa_f32_f16>(@test_value(1.25) T) -> T */
+ /* fn fract<N : num, T : fa_f32_f16>(@test_value(1.25) vec<N, T>) -> vec<N, T> */
/* num overloads */ 2,
/* overloads */ &kOverloads[347],
},
diff --git a/test/tint/builtins/gen/literal/fract/181aa9.wgsl b/test/tint/builtins/gen/literal/fract/181aa9.wgsl
index 835b78a..d439e1b 100644
--- a/test/tint/builtins/gen/literal/fract/181aa9.wgsl
+++ b/test/tint/builtins/gen/literal/fract/181aa9.wgsl
@@ -25,7 +25,7 @@
// fn fract(vec<2, f16>) -> vec<2, f16>
fn fract_181aa9() {
- var res: vec2<f16> = fract(vec2<f16>(1.h));
+ var res: vec2<f16> = fract(vec2<f16>(1.25h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.dxc.hlsl
index e602eda..c888c8f 100644
--- a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_181aa9() {
- vector<float16_t, 2> res = frac((float16_t(1.0h)).xx);
+ vector<float16_t, 2> res = (float16_t(0.25h)).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.glsl
index c837c60..4404f23 100644
--- a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_181aa9() {
- f16vec2 res = fract(f16vec2(1.0hf));
+ f16vec2 res = f16vec2(0.25hf);
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void fract_181aa9() {
- f16vec2 res = fract(f16vec2(1.0hf));
+ f16vec2 res = f16vec2(0.25hf);
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_181aa9() {
- f16vec2 res = fract(f16vec2(1.0hf));
+ f16vec2 res = f16vec2(0.25hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.msl
index c9a1ea8..b915124 100644
--- a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_181aa9() {
- half2 res = fract(half2(1.0h));
+ half2 res = half2(0.25h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.spvasm
index 9f1b31c..e489898 100644
--- a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/181aa9.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_0x1pn2 = OpConstant %half 0x1p-2
+ %16 = OpConstantComposite %v2half %half_0x1pn2 %half_0x1pn2
%_ptr_Function_v2half = OpTypePointer Function %v2half
- %21 = OpConstantNull %v2half
- %22 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v2half
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%fract_181aa9 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v2half Function %21
- %13 = OpExtInst %v2half %16 Fract %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 %fract_181aa9
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %fract_181aa9
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 %fract_181aa9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_181aa9
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %fract_181aa9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %fract_181aa9
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.wgsl
index c67b415..86ca468 100644
--- a/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/181aa9.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_181aa9() {
- var res : vec2<f16> = fract(vec2<f16>(1.0h));
+ var res : vec2<f16> = fract(vec2<f16>(1.25h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/2eddfe.wgsl b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl
new file mode 100644
index 0000000..27effad
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.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 fract(fa) -> fa
+fn fract_2eddfe() {
+ var res = fract(1.25);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_2eddfe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_2eddfe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_2eddfe();
+}
diff --git a/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..c27230f
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_2eddfe();
+ 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() {
+ fract_2eddfe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_2eddfe();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..c27230f
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_2eddfe();
+ 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() {
+ fract_2eddfe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_2eddfe();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.glsl
new file mode 100644
index 0000000..a8d9c20
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+vec4 vertex_main() {
+ fract_2eddfe();
+ 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 fract_2eddfe() {
+ float res = 0.25f;
+}
+
+void fragment_main() {
+ fract_2eddfe();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+void compute_main() {
+ fract_2eddfe();
+}
+
+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/fract/2eddfe.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.msl
new file mode 100644
index 0000000..f9a855f
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_2eddfe();
+ 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() {
+ fract_2eddfe();
+ return;
+}
+
+kernel void compute_main() {
+ fract_2eddfe();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.spvasm
new file mode 100644
index 0000000..0355f37
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.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 %fract_2eddfe "fract_2eddfe"
+ 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_25 = OpConstant %float 0.25
+%_ptr_Function_float = OpTypePointer Function %float
+ %16 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_2eddfe = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %float_0_25
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %fract_2eddfe
+ 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 %fract_2eddfe
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %fract_2eddfe
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.wgsl
new file mode 100644
index 0000000..7d3e6ce
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/2eddfe.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn fract_2eddfe() {
+ var res = fract(1.25);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_2eddfe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_2eddfe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_2eddfe();
+}
diff --git a/test/tint/builtins/gen/literal/fract/498c77.wgsl b/test/tint/builtins/gen/literal/fract/498c77.wgsl
index 13cadd7..83e2bdc 100644
--- a/test/tint/builtins/gen/literal/fract/498c77.wgsl
+++ b/test/tint/builtins/gen/literal/fract/498c77.wgsl
@@ -25,7 +25,7 @@
// fn fract(vec<4, f16>) -> vec<4, f16>
fn fract_498c77() {
- var res: vec4<f16> = fract(vec4<f16>(1.h));
+ var res: vec4<f16> = fract(vec4<f16>(1.25h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.dxc.hlsl
index b58ad69..e3d3cec 100644
--- a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_498c77() {
- vector<float16_t, 4> res = frac((float16_t(1.0h)).xxxx);
+ vector<float16_t, 4> res = (float16_t(0.25h)).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.glsl
index b4f58b9..7fdb86a 100644
--- a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_498c77() {
- f16vec4 res = fract(f16vec4(1.0hf));
+ f16vec4 res = f16vec4(0.25hf);
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void fract_498c77() {
- f16vec4 res = fract(f16vec4(1.0hf));
+ f16vec4 res = f16vec4(0.25hf);
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_498c77() {
- f16vec4 res = fract(f16vec4(1.0hf));
+ f16vec4 res = f16vec4(0.25hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.msl
index 521e56d..61516a2 100644
--- a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_498c77() {
- half4 res = fract(half4(1.0h));
+ half4 res = half4(0.25h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.spvasm
index d4bf720..bb9242b 100644
--- a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/498c77.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_0x1pn2 = OpConstant %half 0x1p-2
+ %16 = OpConstantComposite %v4half %half_0x1pn2 %half_0x1pn2 %half_0x1pn2 %half_0x1pn2
%_ptr_Function_v4half = OpTypePointer Function %v4half
- %21 = OpConstantNull %v4half
- %22 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v4half
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%fract_498c77 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v4half Function %21
- %13 = OpExtInst %v4half %16 Fract %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 %fract_498c77
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %fract_498c77
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 %fract_498c77
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_498c77
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %fract_498c77
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %fract_498c77
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.wgsl
index 3c8ac4e..adbf6ff 100644
--- a/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/498c77.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_498c77() {
- var res : vec4<f16> = fract(vec4<f16>(1.0h));
+ var res : vec4<f16> = fract(vec4<f16>(1.25h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl
new file mode 100644
index 0000000..0ee5db0
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.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 fract(vec<4, fa>) -> vec<4, fa>
+fn fract_7e3f2d() {
+ var res = fract(vec4(1.25));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_7e3f2d();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_7e3f2d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_7e3f2d();
+}
diff --git a/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..cdb4fc8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_7e3f2d() {
+ float4 res = (0.25f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_7e3f2d();
+ 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() {
+ fract_7e3f2d();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_7e3f2d();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..cdb4fc8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_7e3f2d() {
+ float4 res = (0.25f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_7e3f2d();
+ 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() {
+ fract_7e3f2d();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_7e3f2d();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.glsl
new file mode 100644
index 0000000..946ec1d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_7e3f2d() {
+ vec4 res = vec4(0.25f);
+}
+
+vec4 vertex_main() {
+ fract_7e3f2d();
+ 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 fract_7e3f2d() {
+ vec4 res = vec4(0.25f);
+}
+
+void fragment_main() {
+ fract_7e3f2d();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_7e3f2d() {
+ vec4 res = vec4(0.25f);
+}
+
+void compute_main() {
+ fract_7e3f2d();
+}
+
+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/fract/7e3f2d.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.msl
new file mode 100644
index 0000000..ebcbba4
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_7e3f2d() {
+ float4 res = float4(0.25f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_7e3f2d();
+ 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() {
+ fract_7e3f2d();
+ return;
+}
+
+kernel void compute_main() {
+ fract_7e3f2d();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.spvasm
new file mode 100644
index 0000000..fcf64d9
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.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 %fract_7e3f2d "fract_7e3f2d"
+ 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_25 = OpConstant %float 0.25
+ %14 = OpConstantComposite %v4float %float_0_25 %float_0_25 %float_0_25 %float_0_25
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %17 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_7e3f2d = 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 %fract_7e3f2d
+ 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 %fract_7e3f2d
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_7e3f2d
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.wgsl
new file mode 100644
index 0000000..313b058
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/7e3f2d.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn fract_7e3f2d() {
+ var res = fract(vec4(1.25));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_7e3f2d();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_7e3f2d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_7e3f2d();
+}
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl
index 46d9741..3b2112a 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl
@@ -23,7 +23,7 @@
// fn fract(vec<4, f32>) -> vec<4, f32>
fn fract_8bc1e9() {
- var res: vec4<f32> = fract(vec4<f32>(1.f));
+ var res: vec4<f32> = fract(vec4<f32>(1.25f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.dxc.hlsl
index f6a454c..7f353c6 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_8bc1e9() {
- float4 res = frac((1.0f).xxxx);
+ float4 res = (0.25f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.fxc.hlsl
index f6a454c..7f353c6 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_8bc1e9() {
- float4 res = frac((1.0f).xxxx);
+ float4 res = (0.25f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.glsl
index e89b9d8..ecb59a2 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_8bc1e9() {
- vec4 res = fract(vec4(1.0f));
+ vec4 res = vec4(0.25f);
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void fract_8bc1e9() {
- vec4 res = fract(vec4(1.0f));
+ vec4 res = vec4(0.25f);
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void fract_8bc1e9() {
- vec4 res = fract(vec4(1.0f));
+ vec4 res = vec4(0.25f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.msl
index 97bbcef..41c4c87 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_8bc1e9() {
- float4 res = fract(float4(1.0f));
+ float4 res = float4(0.25f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.spvasm
index 0f9bdc3..01e4bb2 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.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_25 = OpConstant %float 0.25
+ %14 = OpConstantComposite %v4float %float_0_25 %float_0_25 %float_0_25 %float_0_25
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %19 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_8bc1e9 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %13 = OpExtInst %v4float %14 Fract %16
- OpStore %res %13
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %19
- %21 = OpLabel
- %22 = OpFunctionCall %void %fract_8bc1e9
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %fract_8bc1e9
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 %fract_8bc1e9
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %fract_8bc1e9
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %30 = OpLabel
- %31 = OpFunctionCall %void %fract_8bc1e9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_8bc1e9
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.wgsl
index 7c99115..487ef1b 100644
--- a/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/8bc1e9.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_8bc1e9() {
- var res : vec4<f32> = fract(vec4<f32>(1.0f));
+ var res : vec4<f32> = fract(vec4<f32>(1.25f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl b/test/tint/builtins/gen/literal/fract/943cb1.wgsl
index 2ccd8f1..1841bab 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl
+++ b/test/tint/builtins/gen/literal/fract/943cb1.wgsl
@@ -23,7 +23,7 @@
// fn fract(vec<2, f32>) -> vec<2, f32>
fn fract_943cb1() {
- var res: vec2<f32> = fract(vec2<f32>(1.f));
+ var res: vec2<f32> = fract(vec2<f32>(1.25f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.dxc.hlsl
index 60f7ce1..29149b5 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_943cb1() {
- float2 res = frac((1.0f).xx);
+ float2 res = (0.25f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.fxc.hlsl
index 60f7ce1..29149b5 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_943cb1() {
- float2 res = frac((1.0f).xx);
+ float2 res = (0.25f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.glsl
index c463977..0bef25d 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_943cb1() {
- vec2 res = fract(vec2(1.0f));
+ vec2 res = vec2(0.25f);
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void fract_943cb1() {
- vec2 res = fract(vec2(1.0f));
+ vec2 res = vec2(0.25f);
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void fract_943cb1() {
- vec2 res = fract(vec2(1.0f));
+ vec2 res = vec2(0.25f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.msl
index ea16cd9..f80f8f8 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_943cb1() {
- float2 res = fract(float2(1.0f));
+ float2 res = float2(0.25f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.spvasm
index debfe32..2f70370 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/943cb1.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_25 = OpConstant %float 0.25
+ %15 = OpConstantComposite %v2float %float_0_25 %float_0_25
%_ptr_Function_v2float = OpTypePointer Function %v2float
- %20 = OpConstantNull %v2float
- %21 = OpTypeFunction %v4float
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_943cb1 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v2float Function %20
- %13 = OpExtInst %v2float %15 Fract %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 %fract_943cb1
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %fract_943cb1
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 %fract_943cb1
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %fract_943cb1
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %fract_943cb1
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %fract_943cb1
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.wgsl
index 21a6738..790e0db 100644
--- a/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/943cb1.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_943cb1() {
- var res : vec2<f32> = fract(vec2<f32>(1.0f));
+ var res : vec2<f32> = fract(vec2<f32>(1.25f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/958a1d.wgsl b/test/tint/builtins/gen/literal/fract/958a1d.wgsl
index 27348ee..f519e63 100644
--- a/test/tint/builtins/gen/literal/fract/958a1d.wgsl
+++ b/test/tint/builtins/gen/literal/fract/958a1d.wgsl
@@ -25,7 +25,7 @@
// fn fract(vec<3, f16>) -> vec<3, f16>
fn fract_958a1d() {
- var res: vec3<f16> = fract(vec3<f16>(1.h));
+ var res: vec3<f16> = fract(vec3<f16>(1.25h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.dxc.hlsl
index 998cc75..f5d91ea 100644
--- a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_958a1d() {
- vector<float16_t, 3> res = frac((float16_t(1.0h)).xxx);
+ vector<float16_t, 3> res = (float16_t(0.25h)).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.glsl
index de3b9ee..95cb787 100644
--- a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_958a1d() {
- f16vec3 res = fract(f16vec3(1.0hf));
+ f16vec3 res = f16vec3(0.25hf);
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void fract_958a1d() {
- f16vec3 res = fract(f16vec3(1.0hf));
+ f16vec3 res = f16vec3(0.25hf);
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_958a1d() {
- f16vec3 res = fract(f16vec3(1.0hf));
+ f16vec3 res = f16vec3(0.25hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.msl
index 9a814ff..5d654de 100644
--- a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_958a1d() {
- half3 res = fract(half3(1.0h));
+ half3 res = half3(0.25h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.spvasm
index 79831a4..bfe99f8 100644
--- a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/958a1d.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_0x1pn2 = OpConstant %half 0x1p-2
+ %16 = OpConstantComposite %v3half %half_0x1pn2 %half_0x1pn2 %half_0x1pn2
%_ptr_Function_v3half = OpTypePointer Function %v3half
- %21 = OpConstantNull %v3half
- %22 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v3half
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%fract_958a1d = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v3half Function %21
- %13 = OpExtInst %v3half %16 Fract %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 %fract_958a1d
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %fract_958a1d
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 %fract_958a1d
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_958a1d
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %fract_958a1d
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %fract_958a1d
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.wgsl
index 5fdd153..edc6410 100644
--- a/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/958a1d.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_958a1d() {
- var res : vec3<f16> = fract(vec3<f16>(1.0h));
+ var res : vec3<f16> = fract(vec3<f16>(1.25h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl b/test/tint/builtins/gen/literal/fract/a49758.wgsl
index 3b4ea30..44c4d1c 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl
+++ b/test/tint/builtins/gen/literal/fract/a49758.wgsl
@@ -23,7 +23,7 @@
// fn fract(vec<3, f32>) -> vec<3, f32>
fn fract_a49758() {
- var res: vec3<f32> = fract(vec3<f32>(1.f));
+ var res: vec3<f32> = fract(vec3<f32>(1.25f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.dxc.hlsl
index ad67971..86bcc35 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_a49758() {
- float3 res = frac((1.0f).xxx);
+ float3 res = (0.25f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.fxc.hlsl
index ad67971..86bcc35 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_a49758() {
- float3 res = frac((1.0f).xxx);
+ float3 res = (0.25f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.glsl
index d6c5415..7723da4 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_a49758() {
- vec3 res = fract(vec3(1.0f));
+ vec3 res = vec3(0.25f);
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void fract_a49758() {
- vec3 res = fract(vec3(1.0f));
+ vec3 res = vec3(0.25f);
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void fract_a49758() {
- vec3 res = fract(vec3(1.0f));
+ vec3 res = vec3(0.25f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.msl
index c59b0de..c42aff4 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_a49758() {
- float3 res = fract(float3(1.0f));
+ float3 res = float3(0.25f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.spvasm
index e132589..3a709c2 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/a49758.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_25 = OpConstant %float 0.25
+ %15 = OpConstantComposite %v3float %float_0_25 %float_0_25 %float_0_25
%_ptr_Function_v3float = OpTypePointer Function %v3float
- %20 = OpConstantNull %v3float
- %21 = OpTypeFunction %v4float
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_a49758 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v3float Function %20
- %13 = OpExtInst %v3float %15 Fract %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 %fract_a49758
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %fract_a49758
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 %fract_a49758
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %fract_a49758
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %fract_a49758
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %fract_a49758
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.wgsl
index 70c8250..e5291fb 100644
--- a/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/a49758.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_a49758() {
- var res : vec3<f32> = fract(vec3<f32>(1.0f));
+ var res : vec3<f32> = fract(vec3<f32>(1.25f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl
index 8ea12ea..007ceb0 100644
--- a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl
+++ b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl
@@ -25,7 +25,7 @@
// fn fract(f16) -> f16
fn fract_eb38ce() {
- var res: f16 = fract(1.h);
+ var res: f16 = fract(1.25h);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.dxc.hlsl
index a4e26da..f9b3793 100644
--- a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_eb38ce() {
- float16_t res = frac(float16_t(1.0h));
+ float16_t res = float16_t(0.25h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.glsl
index dbd83c9..0cb166c 100644
--- a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_eb38ce() {
- float16_t res = fract(1.0hf);
+ float16_t res = 0.25hf;
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void fract_eb38ce() {
- float16_t res = fract(1.0hf);
+ float16_t res = 0.25hf;
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_eb38ce() {
- float16_t res = fract(1.0hf);
+ float16_t res = 0.25hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.msl
index e5b9d42..207c702 100644
--- a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_eb38ce() {
- half res = fract(1.0h);
+ half res = 0.25h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.spvasm
index d4f1736..506c880 100644
--- a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/eb38ce.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_0x1pn2 = OpConstant %half 0x1p-2
%_ptr_Function_half = OpTypePointer Function %half
- %19 = OpConstantNull %half
- %20 = OpTypeFunction %v4float
+ %17 = OpConstantNull %half
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%fract_eb38ce = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %19
- %13 = OpExtInst %half %15 Fract %half_0x1p_0
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_half Function %17
+ OpStore %res %half_0x1pn2
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
- %22 = OpLabel
- %23 = OpFunctionCall %void %fract_eb38ce
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %fract_eb38ce
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 %fract_eb38ce
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %fract_eb38ce
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %fract_eb38ce
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %fract_eb38ce
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.wgsl
index c6aa88c..2573566 100644
--- a/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/eb38ce.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_eb38ce() {
- var res : f16 = fract(1.0h);
+ var res : f16 = fract(1.25h);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/ed00ca.wgsl b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl
new file mode 100644
index 0000000..7ecb626
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.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 fract(vec<2, fa>) -> vec<2, fa>
+fn fract_ed00ca() {
+ var res = fract(vec2(1.25));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed00ca();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed00ca();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed00ca();
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..de1638a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed00ca() {
+ float2 res = (0.25f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed00ca();
+ 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() {
+ fract_ed00ca();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed00ca();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..de1638a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed00ca() {
+ float2 res = (0.25f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed00ca();
+ 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() {
+ fract_ed00ca();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed00ca();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.glsl
new file mode 100644
index 0000000..e6fe3c1
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_ed00ca() {
+ vec2 res = vec2(0.25f);
+}
+
+vec4 vertex_main() {
+ fract_ed00ca();
+ 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 fract_ed00ca() {
+ vec2 res = vec2(0.25f);
+}
+
+void fragment_main() {
+ fract_ed00ca();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_ed00ca() {
+ vec2 res = vec2(0.25f);
+}
+
+void compute_main() {
+ fract_ed00ca();
+}
+
+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/fract/ed00ca.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.msl
new file mode 100644
index 0000000..d44f4ac
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_ed00ca() {
+ float2 res = float2(0.25f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_ed00ca();
+ 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() {
+ fract_ed00ca();
+ return;
+}
+
+kernel void compute_main() {
+ fract_ed00ca();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.spvasm
new file mode 100644
index 0000000..695ff30
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.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 %fract_ed00ca "fract_ed00ca"
+ 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_25 = OpConstant %float 0.25
+ %15 = OpConstantComposite %v2float %float_0_25 %float_0_25
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_ed00ca = 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 %fract_ed00ca
+ 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 %fract_ed00ca
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %fract_ed00ca
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.wgsl
new file mode 100644
index 0000000..dc1698b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed00ca.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn fract_ed00ca() {
+ var res = fract(vec2(1.25));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed00ca();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed00ca();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed00ca();
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed2f79.wgsl b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl
new file mode 100644
index 0000000..b4f0d9d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.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 fract(vec<3, fa>) -> vec<3, fa>
+fn fract_ed2f79() {
+ var res = fract(vec3(1.25));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed2f79();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed2f79();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed2f79();
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..3686b4b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed2f79() {
+ float3 res = (0.25f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed2f79();
+ 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() {
+ fract_ed2f79();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed2f79();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..3686b4b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed2f79() {
+ float3 res = (0.25f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed2f79();
+ 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() {
+ fract_ed2f79();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed2f79();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.glsl
new file mode 100644
index 0000000..9952c8b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_ed2f79() {
+ vec3 res = vec3(0.25f);
+}
+
+vec4 vertex_main() {
+ fract_ed2f79();
+ 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 fract_ed2f79() {
+ vec3 res = vec3(0.25f);
+}
+
+void fragment_main() {
+ fract_ed2f79();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_ed2f79() {
+ vec3 res = vec3(0.25f);
+}
+
+void compute_main() {
+ fract_ed2f79();
+}
+
+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/fract/ed2f79.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.msl
new file mode 100644
index 0000000..64c5555
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_ed2f79() {
+ float3 res = float3(0.25f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_ed2f79();
+ 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() {
+ fract_ed2f79();
+ return;
+}
+
+kernel void compute_main() {
+ fract_ed2f79();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.spvasm
new file mode 100644
index 0000000..5b6913e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.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 %fract_ed2f79 "fract_ed2f79"
+ 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_25 = OpConstant %float 0.25
+ %15 = OpConstantComposite %v3float %float_0_25 %float_0_25 %float_0_25
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_ed2f79 = 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 %fract_ed2f79
+ 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 %fract_ed2f79
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %fract_ed2f79
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.wgsl
new file mode 100644
index 0000000..c042c8c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/fract/ed2f79.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn fract_ed2f79() {
+ var res = fract(vec3(1.25));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed2f79();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed2f79();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed2f79();
+}
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl
index 1fb7db0..8a7bc3d 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl
@@ -23,7 +23,7 @@
// fn fract(f32) -> f32
fn fract_fa5c71() {
- var res: f32 = fract(1.f);
+ var res: f32 = fract(1.25f);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.dxc.hlsl
index dcf44fd..30c1d2a 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_fa5c71() {
- float res = frac(1.0f);
+ float res = 0.25f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.fxc.hlsl
index dcf44fd..30c1d2a 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_fa5c71() {
- float res = frac(1.0f);
+ float res = 0.25f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.glsl b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.glsl
index 6bc91bf..58d2cff 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_fa5c71() {
- float res = fract(1.0f);
+ float res = 0.25f;
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void fract_fa5c71() {
- float res = fract(1.0f);
+ float res = 0.25f;
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void fract_fa5c71() {
- float res = fract(1.0f);
+ float res = 0.25f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.msl b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.msl
index 50baf32..b08afbe 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_fa5c71() {
- float res = fract(1.0f);
+ float res = 0.25f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.spvasm
index 6e73bc5..3a4850d 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.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_25 = OpConstant %float 0.25
%_ptr_Function_float = OpTypePointer Function %float
- %18 = OpTypeFunction %v4float
+ %16 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_fa5c71 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %13 = OpExtInst %float %14 Fract %float_1
- OpStore %res %13
+ OpStore %res %float_0_25
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %18
- %20 = OpLabel
- %21 = OpFunctionCall %void %fract_fa5c71
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %fract_fa5c71
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 %fract_fa5c71
+ %25 = OpLabel
+ %26 = OpFunctionCall %void %fract_fa5c71
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %fract_fa5c71
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %fract_fa5c71
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.wgsl
index 431666a..a614981 100644
--- a/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/fract/fa5c71.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_fa5c71() {
- var res : f32 = fract(1.0f);
+ var res : f32 = fract(1.25f);
}
@vertex
diff --git a/test/tint/builtins/gen/var/fract/181aa9.wgsl b/test/tint/builtins/gen/var/fract/181aa9.wgsl
index 1ffd186..218c38f 100644
--- a/test/tint/builtins/gen/var/fract/181aa9.wgsl
+++ b/test/tint/builtins/gen/var/fract/181aa9.wgsl
@@ -25,7 +25,7 @@
// fn fract(vec<2, f16>) -> vec<2, f16>
fn fract_181aa9() {
- var arg_0 = vec2<f16>(1.h);
+ var arg_0 = vec2<f16>(1.25h);
var res: vec2<f16> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.dxc.hlsl
index 6d73d2e..240fbb9 100644
--- a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_181aa9() {
- vector<float16_t, 2> arg_0 = (float16_t(1.0h)).xx;
+ vector<float16_t, 2> arg_0 = (float16_t(1.25h)).xx;
vector<float16_t, 2> res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.glsl
index f2283f7..06329c5 100644
--- a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_181aa9() {
- f16vec2 arg_0 = f16vec2(1.0hf);
+ f16vec2 arg_0 = f16vec2(1.25hf);
f16vec2 res = fract(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void fract_181aa9() {
- f16vec2 arg_0 = f16vec2(1.0hf);
+ f16vec2 arg_0 = f16vec2(1.25hf);
f16vec2 res = fract(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_181aa9() {
- f16vec2 arg_0 = f16vec2(1.0hf);
+ f16vec2 arg_0 = f16vec2(1.25hf);
f16vec2 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.msl
index a44159f..751c7b5 100644
--- a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_181aa9() {
- half2 arg_0 = half2(1.0h);
+ half2 arg_0 = half2(1.25h);
half2 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.spvasm
index 95c9f98..b50b553 100644
--- a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.spvasm
@@ -38,8 +38,8 @@
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %16 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
+%half_0x1_4p_0 = OpConstant %half 0x1.4p+0
+ %16 = OpConstantComposite %v2half %half_0x1_4p_0 %half_0x1_4p_0
%_ptr_Function_v2half = OpTypePointer Function %v2half
%19 = OpConstantNull %v2half
%24 = OpTypeFunction %v4float
diff --git a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.wgsl
index c65421c..d47bd7f 100644
--- a/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/181aa9.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_181aa9() {
- var arg_0 = vec2<f16>(1.0h);
+ var arg_0 = vec2<f16>(1.25h);
var res : vec2<f16> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/2eddfe.wgsl b/test/tint/builtins/gen/var/fract/2eddfe.wgsl
new file mode 100644
index 0000000..44eb00b
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.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 fract(fa) -> fa
+fn fract_2eddfe() {
+ const arg_0 = 1.25;
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_2eddfe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_2eddfe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_2eddfe();
+}
diff --git a/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..c27230f
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_2eddfe();
+ 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() {
+ fract_2eddfe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_2eddfe();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..c27230f
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_2eddfe();
+ 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() {
+ fract_2eddfe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_2eddfe();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.glsl
new file mode 100644
index 0000000..a8d9c20
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+vec4 vertex_main() {
+ fract_2eddfe();
+ 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 fract_2eddfe() {
+ float res = 0.25f;
+}
+
+void fragment_main() {
+ fract_2eddfe();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+void compute_main() {
+ fract_2eddfe();
+}
+
+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/fract/2eddfe.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.msl
new file mode 100644
index 0000000..f9a855f
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_2eddfe() {
+ float res = 0.25f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_2eddfe();
+ 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() {
+ fract_2eddfe();
+ return;
+}
+
+kernel void compute_main() {
+ fract_2eddfe();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.spvasm
new file mode 100644
index 0000000..0355f37
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.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 %fract_2eddfe "fract_2eddfe"
+ 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_25 = OpConstant %float 0.25
+%_ptr_Function_float = OpTypePointer Function %float
+ %16 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_2eddfe = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %float_0_25
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %fract_2eddfe
+ 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 %fract_2eddfe
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %fract_2eddfe
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.wgsl
new file mode 100644
index 0000000..5379101
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/2eddfe.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn fract_2eddfe() {
+ const arg_0 = 1.25;
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_2eddfe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_2eddfe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_2eddfe();
+}
diff --git a/test/tint/builtins/gen/var/fract/498c77.wgsl b/test/tint/builtins/gen/var/fract/498c77.wgsl
index 5ea4700..9b550e8 100644
--- a/test/tint/builtins/gen/var/fract/498c77.wgsl
+++ b/test/tint/builtins/gen/var/fract/498c77.wgsl
@@ -25,7 +25,7 @@
// fn fract(vec<4, f16>) -> vec<4, f16>
fn fract_498c77() {
- var arg_0 = vec4<f16>(1.h);
+ var arg_0 = vec4<f16>(1.25h);
var res: vec4<f16> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.dxc.hlsl
index 5887de1..d114662 100644
--- a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_498c77() {
- vector<float16_t, 4> arg_0 = (float16_t(1.0h)).xxxx;
+ vector<float16_t, 4> arg_0 = (float16_t(1.25h)).xxxx;
vector<float16_t, 4> res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.glsl
index 1e866f5..6c1a9c1 100644
--- a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_498c77() {
- f16vec4 arg_0 = f16vec4(1.0hf);
+ f16vec4 arg_0 = f16vec4(1.25hf);
f16vec4 res = fract(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void fract_498c77() {
- f16vec4 arg_0 = f16vec4(1.0hf);
+ f16vec4 arg_0 = f16vec4(1.25hf);
f16vec4 res = fract(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_498c77() {
- f16vec4 arg_0 = f16vec4(1.0hf);
+ f16vec4 arg_0 = f16vec4(1.25hf);
f16vec4 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.msl
index 9c08796..928481b 100644
--- a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_498c77() {
- half4 arg_0 = half4(1.0h);
+ half4 arg_0 = half4(1.25h);
half4 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.spvasm
index 2ec1d9d..dd24ec1 100644
--- a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.spvasm
@@ -38,8 +38,8 @@
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %16 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+%half_0x1_4p_0 = OpConstant %half 0x1.4p+0
+ %16 = OpConstantComposite %v4half %half_0x1_4p_0 %half_0x1_4p_0 %half_0x1_4p_0 %half_0x1_4p_0
%_ptr_Function_v4half = OpTypePointer Function %v4half
%19 = OpConstantNull %v4half
%24 = OpTypeFunction %v4float
diff --git a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.wgsl
index 72e50bb..9255273 100644
--- a/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/498c77.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_498c77() {
- var arg_0 = vec4<f16>(1.0h);
+ var arg_0 = vec4<f16>(1.25h);
var res : vec4<f16> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/7e3f2d.wgsl b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl
new file mode 100644
index 0000000..80ad812
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.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 fract(vec<4, fa>) -> vec<4, fa>
+fn fract_7e3f2d() {
+ const arg_0 = vec4(1.25);
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_7e3f2d();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_7e3f2d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_7e3f2d();
+}
diff --git a/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..cdb4fc8
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_7e3f2d() {
+ float4 res = (0.25f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_7e3f2d();
+ 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() {
+ fract_7e3f2d();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_7e3f2d();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..cdb4fc8
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_7e3f2d() {
+ float4 res = (0.25f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_7e3f2d();
+ 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() {
+ fract_7e3f2d();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_7e3f2d();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.glsl
new file mode 100644
index 0000000..946ec1d
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_7e3f2d() {
+ vec4 res = vec4(0.25f);
+}
+
+vec4 vertex_main() {
+ fract_7e3f2d();
+ 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 fract_7e3f2d() {
+ vec4 res = vec4(0.25f);
+}
+
+void fragment_main() {
+ fract_7e3f2d();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_7e3f2d() {
+ vec4 res = vec4(0.25f);
+}
+
+void compute_main() {
+ fract_7e3f2d();
+}
+
+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/fract/7e3f2d.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.msl
new file mode 100644
index 0000000..ebcbba4
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_7e3f2d() {
+ float4 res = float4(0.25f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_7e3f2d();
+ 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() {
+ fract_7e3f2d();
+ return;
+}
+
+kernel void compute_main() {
+ fract_7e3f2d();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.spvasm
new file mode 100644
index 0000000..fcf64d9
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.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 %fract_7e3f2d "fract_7e3f2d"
+ 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_25 = OpConstant %float 0.25
+ %14 = OpConstantComposite %v4float %float_0_25 %float_0_25 %float_0_25 %float_0_25
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %17 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_7e3f2d = 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 %fract_7e3f2d
+ 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 %fract_7e3f2d
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_7e3f2d
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.wgsl
new file mode 100644
index 0000000..1314787
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/7e3f2d.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn fract_7e3f2d() {
+ const arg_0 = vec4(1.25);
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_7e3f2d();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_7e3f2d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_7e3f2d();
+}
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl
index 1591a97..671bed0 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl
@@ -23,7 +23,7 @@
// fn fract(vec<4, f32>) -> vec<4, f32>
fn fract_8bc1e9() {
- var arg_0 = vec4<f32>(1.f);
+ var arg_0 = vec4<f32>(1.25f);
var res: vec4<f32> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.dxc.hlsl
index 3fc1143..60cd54a 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_8bc1e9() {
- float4 arg_0 = (1.0f).xxxx;
+ float4 arg_0 = (1.25f).xxxx;
float4 res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.fxc.hlsl
index 3fc1143..60cd54a 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_8bc1e9() {
- float4 arg_0 = (1.0f).xxxx;
+ float4 arg_0 = (1.25f).xxxx;
float4 res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.glsl
index a931954..268b77c 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_8bc1e9() {
- vec4 arg_0 = vec4(1.0f);
+ vec4 arg_0 = vec4(1.25f);
vec4 res = fract(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void fract_8bc1e9() {
- vec4 arg_0 = vec4(1.0f);
+ vec4 arg_0 = vec4(1.25f);
vec4 res = fract(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void fract_8bc1e9() {
- vec4 arg_0 = vec4(1.0f);
+ vec4 arg_0 = vec4(1.25f);
vec4 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.msl
index de4a03d..dbedba1 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_8bc1e9() {
- float4 arg_0 = float4(1.0f);
+ float4 arg_0 = float4(1.25f);
float4 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.spvasm
index 2fce3d9..1c8b35b 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 35
; Schema: 0
OpCapability Shader
%18 = OpExtInstImport "GLSL.std.450"
@@ -32,10 +32,11 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %float_1 = OpConstant %float 1
- %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+ %float_1_25 = OpConstant %float 1.25
+ %14 = OpConstantComposite %v4float %float_1_25 %float_1_25 %float_1_25 %float_1_25
%_ptr_Function_v4float = OpTypePointer Function %v4float
%21 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_8bc1e9 = OpFunction %void None %9
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v4float Function %5
@@ -59,12 +60,12 @@
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %fract_8bc1e9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %fract_8bc1e9
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %fract_8bc1e9
+ %33 = OpLabel
+ %34 = OpFunctionCall %void %fract_8bc1e9
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.wgsl
index 31c9a04..a1db1d3 100644
--- a/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/8bc1e9.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_8bc1e9() {
- var arg_0 = vec4<f32>(1.0f);
+ var arg_0 = vec4<f32>(1.25f);
var res : vec4<f32> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl b/test/tint/builtins/gen/var/fract/943cb1.wgsl
index 19a5428..4db50d4 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl
@@ -23,7 +23,7 @@
// fn fract(vec<2, f32>) -> vec<2, f32>
fn fract_943cb1() {
- var arg_0 = vec2<f32>(1.f);
+ var arg_0 = vec2<f32>(1.25f);
var res: vec2<f32> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.dxc.hlsl
index 7ebeca2..32341a2 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_943cb1() {
- float2 arg_0 = (1.0f).xx;
+ float2 arg_0 = (1.25f).xx;
float2 res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.fxc.hlsl
index 7ebeca2..32341a2 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_943cb1() {
- float2 arg_0 = (1.0f).xx;
+ float2 arg_0 = (1.25f).xx;
float2 res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.glsl
index 0cdaa88..a5ced40 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_943cb1() {
- vec2 arg_0 = vec2(1.0f);
+ vec2 arg_0 = vec2(1.25f);
vec2 res = fract(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void fract_943cb1() {
- vec2 arg_0 = vec2(1.0f);
+ vec2 arg_0 = vec2(1.25f);
vec2 res = fract(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void fract_943cb1() {
- vec2 arg_0 = vec2(1.0f);
+ vec2 arg_0 = vec2(1.25f);
vec2 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.msl
index 1d5202f..e2c7c6a 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_943cb1() {
- float2 arg_0 = float2(1.0f);
+ float2 arg_0 = float2(1.25f);
float2 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.spvasm
index 1c141d5..bfc7d49 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 37
; Schema: 0
OpCapability Shader
%20 = OpExtInstImport "GLSL.std.450"
@@ -33,11 +33,12 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
- %float_1 = OpConstant %float 1
- %15 = OpConstantComposite %v2float %float_1 %float_1
+ %float_1_25 = OpConstant %float 1.25
+ %15 = OpConstantComposite %v2float %float_1_25 %float_1_25
%_ptr_Function_v2float = OpTypePointer Function %v2float
%18 = OpConstantNull %v2float
%23 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_943cb1 = OpFunction %void None %9
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v2float Function %18
@@ -61,12 +62,12 @@
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %fract_943cb1
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %fract_943cb1
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %fract_943cb1
+ %35 = OpLabel
+ %36 = OpFunctionCall %void %fract_943cb1
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.wgsl
index 456ab98..b0fd64f 100644
--- a/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/943cb1.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_943cb1() {
- var arg_0 = vec2<f32>(1.0f);
+ var arg_0 = vec2<f32>(1.25f);
var res : vec2<f32> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/958a1d.wgsl b/test/tint/builtins/gen/var/fract/958a1d.wgsl
index dbcf68c..bec9395 100644
--- a/test/tint/builtins/gen/var/fract/958a1d.wgsl
+++ b/test/tint/builtins/gen/var/fract/958a1d.wgsl
@@ -25,7 +25,7 @@
// fn fract(vec<3, f16>) -> vec<3, f16>
fn fract_958a1d() {
- var arg_0 = vec3<f16>(1.h);
+ var arg_0 = vec3<f16>(1.25h);
var res: vec3<f16> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.dxc.hlsl
index 3fd76d1..a63f1dc 100644
--- a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_958a1d() {
- vector<float16_t, 3> arg_0 = (float16_t(1.0h)).xxx;
+ vector<float16_t, 3> arg_0 = (float16_t(1.25h)).xxx;
vector<float16_t, 3> res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.glsl
index 99bf6a5..2cbca6f 100644
--- a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_958a1d() {
- f16vec3 arg_0 = f16vec3(1.0hf);
+ f16vec3 arg_0 = f16vec3(1.25hf);
f16vec3 res = fract(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void fract_958a1d() {
- f16vec3 arg_0 = f16vec3(1.0hf);
+ f16vec3 arg_0 = f16vec3(1.25hf);
f16vec3 res = fract(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_958a1d() {
- f16vec3 arg_0 = f16vec3(1.0hf);
+ f16vec3 arg_0 = f16vec3(1.25hf);
f16vec3 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.msl
index 1d0856f..9eb9bf4 100644
--- a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_958a1d() {
- half3 arg_0 = half3(1.0h);
+ half3 arg_0 = half3(1.25h);
half3 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.spvasm
index b0a0294..c7617e2 100644
--- a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.spvasm
@@ -38,8 +38,8 @@
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %16 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+%half_0x1_4p_0 = OpConstant %half 0x1.4p+0
+ %16 = OpConstantComposite %v3half %half_0x1_4p_0 %half_0x1_4p_0 %half_0x1_4p_0
%_ptr_Function_v3half = OpTypePointer Function %v3half
%19 = OpConstantNull %v3half
%24 = OpTypeFunction %v4float
diff --git a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.wgsl
index e573af5..9a710e3 100644
--- a/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/958a1d.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_958a1d() {
- var arg_0 = vec3<f16>(1.0h);
+ var arg_0 = vec3<f16>(1.25h);
var res : vec3<f16> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl b/test/tint/builtins/gen/var/fract/a49758.wgsl
index cf4b0bc..5be115e 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl
@@ -23,7 +23,7 @@
// fn fract(vec<3, f32>) -> vec<3, f32>
fn fract_a49758() {
- var arg_0 = vec3<f32>(1.f);
+ var arg_0 = vec3<f32>(1.25f);
var res: vec3<f32> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.dxc.hlsl
index cbd7af2..911008e 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_a49758() {
- float3 arg_0 = (1.0f).xxx;
+ float3 arg_0 = (1.25f).xxx;
float3 res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.fxc.hlsl
index cbd7af2..911008e 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_a49758() {
- float3 arg_0 = (1.0f).xxx;
+ float3 arg_0 = (1.25f).xxx;
float3 res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.glsl
index 0f4157f..9fcd774 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_a49758() {
- vec3 arg_0 = vec3(1.0f);
+ vec3 arg_0 = vec3(1.25f);
vec3 res = fract(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void fract_a49758() {
- vec3 arg_0 = vec3(1.0f);
+ vec3 arg_0 = vec3(1.25f);
vec3 res = fract(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void fract_a49758() {
- vec3 arg_0 = vec3(1.0f);
+ vec3 arg_0 = vec3(1.25f);
vec3 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.msl
index 2814c3e..e5b30f8 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_a49758() {
- float3 arg_0 = float3(1.0f);
+ float3 arg_0 = float3(1.25f);
float3 res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.spvasm
index b2d7346..517ce36 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 37
; Schema: 0
OpCapability Shader
%20 = OpExtInstImport "GLSL.std.450"
@@ -33,11 +33,12 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%v3float = OpTypeVector %float 3
- %float_1 = OpConstant %float 1
- %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+ %float_1_25 = OpConstant %float 1.25
+ %15 = OpConstantComposite %v3float %float_1_25 %float_1_25 %float_1_25
%_ptr_Function_v3float = OpTypePointer Function %v3float
%18 = OpConstantNull %v3float
%23 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_a49758 = OpFunction %void None %9
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v3float Function %18
@@ -61,12 +62,12 @@
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %fract_a49758
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %fract_a49758
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %fract_a49758
+ %35 = OpLabel
+ %36 = OpFunctionCall %void %fract_a49758
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.wgsl
index 6373452..103c12a 100644
--- a/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/a49758.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_a49758() {
- var arg_0 = vec3<f32>(1.0f);
+ var arg_0 = vec3<f32>(1.25f);
var res : vec3<f32> = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/eb38ce.wgsl b/test/tint/builtins/gen/var/fract/eb38ce.wgsl
index 27a5dbc..52ca757 100644
--- a/test/tint/builtins/gen/var/fract/eb38ce.wgsl
+++ b/test/tint/builtins/gen/var/fract/eb38ce.wgsl
@@ -25,7 +25,7 @@
// fn fract(f16) -> f16
fn fract_eb38ce() {
- var arg_0 = 1.h;
+ var arg_0 = 1.25h;
var res: f16 = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.dxc.hlsl
index f815007..3129c7d 100644
--- a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_eb38ce() {
- float16_t arg_0 = float16_t(1.0h);
+ float16_t arg_0 = float16_t(1.25h);
float16_t res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.glsl
index c463851..9fdbf1f 100644
--- a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_eb38ce() {
- float16_t arg_0 = 1.0hf;
+ float16_t arg_0 = 1.25hf;
float16_t res = fract(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void fract_eb38ce() {
- float16_t arg_0 = 1.0hf;
+ float16_t arg_0 = 1.25hf;
float16_t res = fract(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void fract_eb38ce() {
- float16_t arg_0 = 1.0hf;
+ float16_t arg_0 = 1.25hf;
float16_t res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.msl
index 69756a8..5b3e3ba 100644
--- a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_eb38ce() {
- half arg_0 = 1.0h;
+ half arg_0 = 1.25h;
half res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.spvasm
index d618092..447246a 100644
--- a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.spvasm
@@ -37,7 +37,7 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
-%half_0x1p_0 = OpConstant %half 0x1p+0
+%half_0x1_4p_0 = OpConstant %half 0x1.4p+0
%_ptr_Function_half = OpTypePointer Function %half
%17 = OpConstantNull %half
%22 = OpTypeFunction %v4float
@@ -46,7 +46,7 @@
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_half Function %17
%res = OpVariable %_ptr_Function_half Function %17
- OpStore %arg_0 %half_0x1p_0
+ OpStore %arg_0 %half_0x1_4p_0
%20 = OpLoad %half %arg_0
%18 = OpExtInst %half %19 Fract %20
OpStore %res %18
diff --git a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.wgsl
index 51cf528..ae970ef 100644
--- a/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/eb38ce.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn fract_eb38ce() {
- var arg_0 = 1.0h;
+ var arg_0 = 1.25h;
var res : f16 = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/ed00ca.wgsl b/test/tint/builtins/gen/var/fract/ed00ca.wgsl
new file mode 100644
index 0000000..beaa8e8
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.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 fract(vec<2, fa>) -> vec<2, fa>
+fn fract_ed00ca() {
+ const arg_0 = vec2(1.25);
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed00ca();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed00ca();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed00ca();
+}
diff --git a/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..de1638a
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed00ca() {
+ float2 res = (0.25f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed00ca();
+ 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() {
+ fract_ed00ca();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed00ca();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..de1638a
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed00ca() {
+ float2 res = (0.25f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed00ca();
+ 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() {
+ fract_ed00ca();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed00ca();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.glsl
new file mode 100644
index 0000000..e6fe3c1
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_ed00ca() {
+ vec2 res = vec2(0.25f);
+}
+
+vec4 vertex_main() {
+ fract_ed00ca();
+ 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 fract_ed00ca() {
+ vec2 res = vec2(0.25f);
+}
+
+void fragment_main() {
+ fract_ed00ca();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_ed00ca() {
+ vec2 res = vec2(0.25f);
+}
+
+void compute_main() {
+ fract_ed00ca();
+}
+
+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/fract/ed00ca.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.msl
new file mode 100644
index 0000000..d44f4ac
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_ed00ca() {
+ float2 res = float2(0.25f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_ed00ca();
+ 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() {
+ fract_ed00ca();
+ return;
+}
+
+kernel void compute_main() {
+ fract_ed00ca();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.spvasm
new file mode 100644
index 0000000..695ff30
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.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 %fract_ed00ca "fract_ed00ca"
+ 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_25 = OpConstant %float 0.25
+ %15 = OpConstantComposite %v2float %float_0_25 %float_0_25
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_ed00ca = 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 %fract_ed00ca
+ 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 %fract_ed00ca
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %fract_ed00ca
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.wgsl
new file mode 100644
index 0000000..1cbe7fb
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed00ca.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn fract_ed00ca() {
+ const arg_0 = vec2(1.25);
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed00ca();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed00ca();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed00ca();
+}
diff --git a/test/tint/builtins/gen/var/fract/ed2f79.wgsl b/test/tint/builtins/gen/var/fract/ed2f79.wgsl
new file mode 100644
index 0000000..c2a1083
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.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 fract(vec<3, fa>) -> vec<3, fa>
+fn fract_ed2f79() {
+ const arg_0 = vec3(1.25);
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed2f79();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed2f79();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed2f79();
+}
diff --git a/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..3686b4b
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed2f79() {
+ float3 res = (0.25f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed2f79();
+ 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() {
+ fract_ed2f79();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed2f79();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..3686b4b
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void fract_ed2f79() {
+ float3 res = (0.25f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ fract_ed2f79();
+ 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() {
+ fract_ed2f79();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ fract_ed2f79();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.glsl
new file mode 100644
index 0000000..9952c8b
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void fract_ed2f79() {
+ vec3 res = vec3(0.25f);
+}
+
+vec4 vertex_main() {
+ fract_ed2f79();
+ 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 fract_ed2f79() {
+ vec3 res = vec3(0.25f);
+}
+
+void fragment_main() {
+ fract_ed2f79();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void fract_ed2f79() {
+ vec3 res = vec3(0.25f);
+}
+
+void compute_main() {
+ fract_ed2f79();
+}
+
+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/fract/ed2f79.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.msl
new file mode 100644
index 0000000..64c5555
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void fract_ed2f79() {
+ float3 res = float3(0.25f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ fract_ed2f79();
+ 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() {
+ fract_ed2f79();
+ return;
+}
+
+kernel void compute_main() {
+ fract_ed2f79();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.spvasm
new file mode 100644
index 0000000..5b6913e
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.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 %fract_ed2f79 "fract_ed2f79"
+ 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_25 = OpConstant %float 0.25
+ %15 = OpConstantComposite %v3float %float_0_25 %float_0_25 %float_0_25
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%fract_ed2f79 = 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 %fract_ed2f79
+ 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 %fract_ed2f79
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %fract_ed2f79
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.wgsl
new file mode 100644
index 0000000..e4dd2b6
--- /dev/null
+++ b/test/tint/builtins/gen/var/fract/ed2f79.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn fract_ed2f79() {
+ const arg_0 = vec3(1.25);
+ var res = fract(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ fract_ed2f79();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ fract_ed2f79();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ fract_ed2f79();
+}
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl b/test/tint/builtins/gen/var/fract/fa5c71.wgsl
index 1f6235d..479ff32 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl
@@ -23,7 +23,7 @@
// fn fract(f32) -> f32
fn fract_fa5c71() {
- var arg_0 = 1.f;
+ var arg_0 = 1.25f;
var res: f32 = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.dxc.hlsl
index c24fc77..0547a42 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void fract_fa5c71() {
- float arg_0 = 1.0f;
+ float arg_0 = 1.25f;
float res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.fxc.hlsl
index c24fc77..0547a42 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void fract_fa5c71() {
- float arg_0 = 1.0f;
+ float arg_0 = 1.25f;
float res = frac(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.glsl b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.glsl
index 1727089..ffe50f0 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void fract_fa5c71() {
- float arg_0 = 1.0f;
+ float arg_0 = 1.25f;
float res = fract(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void fract_fa5c71() {
- float arg_0 = 1.0f;
+ float arg_0 = 1.25f;
float res = fract(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void fract_fa5c71() {
- float arg_0 = 1.0f;
+ float arg_0 = 1.25f;
float res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.msl b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.msl
index 28643cc..4a98d21 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void fract_fa5c71() {
- float arg_0 = 1.0f;
+ float arg_0 = 1.25f;
float res = fract(arg_0);
}
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.spvasm b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.spvasm
index 18cc7aa..32de0e0 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 33
+; Bound: 34
; Schema: 0
OpCapability Shader
%17 = OpExtInstImport "GLSL.std.450"
@@ -32,14 +32,15 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %float_1 = OpConstant %float 1
+ %float_1_25 = OpConstant %float 1.25
%_ptr_Function_float = OpTypePointer Function %float
%20 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%fract_fa5c71 = OpFunction %void None %9
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_float Function %8
%res = OpVariable %_ptr_Function_float Function %8
- OpStore %arg_0 %float_1
+ OpStore %arg_0 %float_1_25
%18 = OpLoad %float %arg_0
%16 = OpExtInst %float %17 Fract %18
OpStore %res %16
@@ -58,12 +59,12 @@
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %28 = OpLabel
- %29 = OpFunctionCall %void %fract_fa5c71
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %fract_fa5c71
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %fract_fa5c71
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %fract_fa5c71
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.wgsl b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.wgsl
index e69460b..0ca4890 100644
--- a/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/fract/fa5c71.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn fract_fa5c71() {
- var arg_0 = 1.0f;
+ var arg_0 = 1.25f;
var res : f32 = fract(arg_0);
}