diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 0511078618..5a088db72c 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -547,8 +547,8 @@ fn sqrt(vec) -> vec @const fn tanh(T) -> T @const fn tanh(vec) -> vec fn transpose(mat) -> mat -fn trunc(T) -> T -fn trunc(vec) -> vec +@const fn trunc(@test_value(1.5) T) -> T +@const fn trunc(@test_value(1.5) vec) -> vec @const fn unpack2x16float(u32) -> vec2 @const fn unpack2x16snorm(u32) -> vec2 @const fn unpack2x16unorm(u32) -> vec2 diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index b1d4cbf4c6..251690f268 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -2401,6 +2401,18 @@ ConstEval::Result ConstEval::tanh(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0]); } +ConstEval::Result ConstEval::trunc(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto i) { + return CreateElement(builder, c0->Type(), decltype(i)(std::trunc(i.value))); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::unpack2x16float(const sem::Type* ty, utils::VectorRef args, const Source& source) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 5c7062fb39..e64511baf1 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -737,6 +737,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// trunc builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result trunc(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// unpack2x16float 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 ac67054bfd..b23cc0ceb5 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1693,6 +1693,26 @@ INSTANTIATE_TEST_SUITE_P( // TanhCases(), TanhCases())))); +template +std::vector TruncCases() { + std::vector cases = {C({T(0)}, T(0)), // + C({-T(0)}, -T(0)), // + C({T(1.5)}, T(1)), // + C({-T(1.5)}, -T(1)), + + // Vector tests + C({Vec(T(0.0), T(1.5), -T(2.2))}, Vec(T(0), T(1), -T(2)))}; + + return cases; +} +INSTANTIATE_TEST_SUITE_P( // + Trunc, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kTrunc), + testing::ValuesIn(Concat(TruncCases(), // + TruncCases(), + TruncCases())))); + std::vector Unpack4x8snormCases() { return { C({Val(u32(0x0000'0000))}, Vec(f32(0), f32(0), f32(0), f32(0))), diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 4c13e0b33d..66bbf722e9 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12729,24 +12729,24 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[977], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::trunc, }, { /* [367] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[5], /* parameters */ &kParameters[976], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::trunc, }, { /* [368] */ @@ -14551,8 +14551,8 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [79] */ - /* fn trunc(T) -> T */ - /* fn trunc(vec) -> vec */ + /* fn trunc(@test_value(1.5) T) -> T */ + /* fn trunc(@test_value(1.5) vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[366], }, diff --git a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl index 5a2495e3ec..1f706a8492 100644 --- a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl +++ b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(vec<3, f16>) -> vec<3, f16> fn trunc_103ab8() { - var res: vec3 = trunc(vec3(1.h)); + var res: vec3 = trunc(vec3(1.5h)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.dxc.hlsl index ffe1f6e675..6d8f7b3b45 100644 --- a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_103ab8() { - vector res = trunc((float16_t(1.0h)).xxx); + vector res = (float16_t(1.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.glsl index 946f9f3431..fc8d55c5fa 100644 --- a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_103ab8() { - f16vec3 res = trunc(f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void trunc_103ab8() { - f16vec3 res = trunc(f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_103ab8() { - f16vec3 res = trunc(f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.msl index 247d36ce94..0714cab5f0 100644 --- a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_103ab8() { - half3 res = trunc(half3(1.0h)); + half3 res = half3(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.spvasm index 537ed0be20..883bfc30f5 100644 --- a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/103ab8.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" @@ -38,37 +37,36 @@ %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 + %16 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %trunc_103ab8 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Trunc %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 %trunc_103ab8 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %trunc_103ab8 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 %trunc_103ab8 + %29 = OpLabel + %30 = OpFunctionCall %void %trunc_103ab8 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %trunc_103ab8 + %32 = OpLabel + %33 = OpFunctionCall %void %trunc_103ab8 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.wgsl index 260b7fae18..664c63b600 100644 --- a/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/103ab8.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_103ab8() { - var res : vec3 = trunc(vec3(1.0h)); + var res : vec3 = trunc(vec3(1.5h)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/117396.wgsl b/test/tint/builtins/gen/literal/trunc/117396.wgsl new file mode 100644 index 0000000000..04ee0904ae --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.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 trunc(vec<3, fa>) -> vec<3, fa> +fn trunc_117396() { + var res = trunc(vec3(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_117396(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_117396(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_117396(); +} diff --git a/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..d3f4162f0d --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_117396() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_117396(); + 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() { + trunc_117396(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_117396(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..d3f4162f0d --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_117396() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_117396(); + 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() { + trunc_117396(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_117396(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.glsl new file mode 100644 index 0000000000..f81df1368d --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_117396() { + vec3 res = vec3(1.0f); +} + +vec4 vertex_main() { + trunc_117396(); + 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 trunc_117396() { + vec3 res = vec3(1.0f); +} + +void fragment_main() { + trunc_117396(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_117396() { + vec3 res = vec3(1.0f); +} + +void compute_main() { + trunc_117396(); +} + +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/trunc/117396.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.msl new file mode 100644 index 0000000000..0fb23c3b8a --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_117396() { + float3 res = float3(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_117396(); + 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() { + trunc_117396(); + return; +} + +kernel void compute_main() { + trunc_117396(); + return; +} + diff --git a/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.spvasm new file mode 100644 index 0000000000..9b9d61cec3 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %trunc_117396 "trunc_117396" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float +%trunc_117396 = 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 %trunc_117396 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_117396 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_117396 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.wgsl new file mode 100644 index 0000000000..439df0cc48 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/117396.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn trunc_117396() { + var res = trunc(vec3(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_117396(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_117396(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_117396(); +} diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl b/test/tint/builtins/gen/literal/trunc/562d05.wgsl index 8b5dd3f7a9..df7c2c55ad 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl @@ -23,7 +23,7 @@ // fn trunc(vec<3, f32>) -> vec<3, f32> fn trunc_562d05() { - var res: vec3 = trunc(vec3(1.f)); + var res: vec3 = trunc(vec3(1.5f)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.dxc.hlsl index 070bd71358..23fbea5738 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_562d05() { - float3 res = trunc((1.0f).xxx); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.fxc.hlsl index 070bd71358..23fbea5738 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_562d05() { - float3 res = trunc((1.0f).xxx); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.glsl index ef1026e378..96d2070ac8 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_562d05() { - vec3 res = trunc(vec3(1.0f)); + vec3 res = vec3(1.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void trunc_562d05() { - vec3 res = trunc(vec3(1.0f)); + vec3 res = vec3(1.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void trunc_562d05() { - vec3 res = trunc(vec3(1.0f)); + vec3 res = vec3(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.msl index 28d2dbccb7..d7d1b1c84c 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_562d05() { - float3 res = trunc(float3(1.0f)); + float3 res = float3(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.spvasm index 33af82417f..bee444b8bb 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; 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" @@ -33,36 +32,35 @@ %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float %trunc_562d05 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Trunc %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 %trunc_562d05 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %trunc_562d05 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 %trunc_562d05 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_562d05 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %trunc_562d05 + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_562d05 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.wgsl index c6d3bb0ad3..b47c5817de 100644 --- a/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/562d05.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_562d05() { - var res : vec3 = trunc(vec3(1.0f)); + var res : vec3 = trunc(vec3(1.5f)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl new file mode 100644 index 0000000000..c57af89e92 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.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 trunc(fa) -> fa +fn trunc_7d6ded() { + var res = trunc(1.5); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_7d6ded(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_7d6ded(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_7d6ded(); +} diff --git a/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..faba2f89cc --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_7d6ded() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_7d6ded(); + 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() { + trunc_7d6ded(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_7d6ded(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..faba2f89cc --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_7d6ded() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_7d6ded(); + 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() { + trunc_7d6ded(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_7d6ded(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.glsl new file mode 100644 index 0000000000..c25da0be76 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_7d6ded() { + float res = 1.0f; +} + +vec4 vertex_main() { + trunc_7d6ded(); + 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 trunc_7d6ded() { + float res = 1.0f; +} + +void fragment_main() { + trunc_7d6ded(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_7d6ded() { + float res = 1.0f; +} + +void compute_main() { + trunc_7d6ded(); +} + +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/trunc/7d6ded.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.msl new file mode 100644 index 0000000000..1bf5a61e77 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_7d6ded() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_7d6ded(); + 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() { + trunc_7d6ded(); + return; +} + +kernel void compute_main() { + trunc_7d6ded(); + return; +} + diff --git a/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.spvasm new file mode 100644 index 0000000000..0b3118bfa6 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.spvasm @@ -0,0 +1,63 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 29 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %trunc_7d6ded "trunc_7d6ded" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float +%trunc_7d6ded = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %trunc_7d6ded + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %trunc_7d6ded + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_7d6ded + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.wgsl new file mode 100644 index 0000000000..785f4b40ab --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/7d6ded.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn trunc_7d6ded() { + var res = trunc(1.5); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_7d6ded(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_7d6ded(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_7d6ded(); +} diff --git a/test/tint/builtins/gen/literal/trunc/a56109.wgsl b/test/tint/builtins/gen/literal/trunc/a56109.wgsl index 51ea764cd2..56f4c98516 100644 --- a/test/tint/builtins/gen/literal/trunc/a56109.wgsl +++ b/test/tint/builtins/gen/literal/trunc/a56109.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(vec<2, f16>) -> vec<2, f16> fn trunc_a56109() { - var res: vec2 = trunc(vec2(1.h)); + var res: vec2 = trunc(vec2(1.5h)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.dxc.hlsl index ed119b9763..05004064ec 100644 --- a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_a56109() { - vector res = trunc((float16_t(1.0h)).xx); + vector res = (float16_t(1.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.glsl index 30a7a09a45..7ad257ce5c 100644 --- a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_a56109() { - f16vec2 res = trunc(f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void trunc_a56109() { - f16vec2 res = trunc(f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_a56109() { - f16vec2 res = trunc(f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.msl index 01e926600a..78261cc61e 100644 --- a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_a56109() { - half2 res = trunc(half2(1.0h)); + half2 res = half2(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.spvasm index 1dc8bf31d3..636608a8b6 100644 --- a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/a56109.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" @@ -38,37 +37,36 @@ %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 %half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 + %16 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %trunc_a56109 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Trunc %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 %trunc_a56109 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %trunc_a56109 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 %trunc_a56109 + %29 = OpLabel + %30 = OpFunctionCall %void %trunc_a56109 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %trunc_a56109 + %32 = OpLabel + %33 = OpFunctionCall %void %trunc_a56109 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.wgsl index 7051d16c4f..06337eb8fd 100644 --- a/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/a56109.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_a56109() { - var res : vec2 = trunc(vec2(1.0h)); + var res : vec2 = trunc(vec2(1.5h)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/c12555.wgsl b/test/tint/builtins/gen/literal/trunc/c12555.wgsl new file mode 100644 index 0000000000..870882cf7e --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.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 trunc(vec<2, fa>) -> vec<2, fa> +fn trunc_c12555() { + var res = trunc(vec2(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_c12555(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_c12555(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_c12555(); +} diff --git a/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..bb9d35f671 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_c12555() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_c12555(); + 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() { + trunc_c12555(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_c12555(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..bb9d35f671 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_c12555() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_c12555(); + 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() { + trunc_c12555(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_c12555(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.glsl new file mode 100644 index 0000000000..bcd6a46cbb --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_c12555() { + vec2 res = vec2(1.0f); +} + +vec4 vertex_main() { + trunc_c12555(); + 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 trunc_c12555() { + vec2 res = vec2(1.0f); +} + +void fragment_main() { + trunc_c12555(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_c12555() { + vec2 res = vec2(1.0f); +} + +void compute_main() { + trunc_c12555(); +} + +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/trunc/c12555.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.msl new file mode 100644 index 0000000000..0a7ef276c0 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_c12555() { + float2 res = float2(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_c12555(); + 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() { + trunc_c12555(); + return; +} + +kernel void compute_main() { + trunc_c12555(); + return; +} + diff --git a/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.spvasm new file mode 100644 index 0000000000..5b3cd3a7df --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %trunc_c12555 "trunc_c12555" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v2float %float_1 %float_1 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float +%trunc_c12555 = 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 %trunc_c12555 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_c12555 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_c12555 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.wgsl new file mode 100644 index 0000000000..a7508ca823 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/c12555.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn trunc_c12555() { + var res = trunc(vec2(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_c12555(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_c12555(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_c12555(); +} diff --git a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl index 32f443a641..bd92fb783e 100644 --- a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl +++ b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(f16) -> f16 fn trunc_cc2b0d() { - var res: f16 = trunc(1.h); + var res: f16 = trunc(1.5h); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.dxc.hlsl index 92d0f9d977..800b327232 100644 --- a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_cc2b0d() { - float16_t res = trunc(float16_t(1.0h)); + float16_t res = float16_t(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.glsl index 00e8be05fd..5dec4bffaf 100644 --- a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_cc2b0d() { - float16_t res = trunc(1.0hf); + float16_t res = 1.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void trunc_cc2b0d() { - float16_t res = trunc(1.0hf); + float16_t res = 1.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_cc2b0d() { - float16_t res = trunc(1.0hf); + float16_t res = 1.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.msl index 785962cb1f..3982531590 100644 --- a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_cc2b0d() { - half res = trunc(1.0h); + half res = 1.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.spvasm index 71302f5148..d6020f29c0 100644 --- a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/cc2b0d.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" @@ -38,35 +37,34 @@ %half = OpTypeFloat 16 %half_0x1p_0 = OpConstant %half 0x1p+0 %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %trunc_cc2b0d = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Trunc %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1p_0 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %trunc_cc2b0d +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %trunc_cc2b0d 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 %trunc_cc2b0d + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_cc2b0d OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %trunc_cc2b0d + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_cc2b0d OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.wgsl index 6963297c31..ab1f7adb71 100644 --- a/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/cc2b0d.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_cc2b0d() { - var res : f16 = trunc(1.0h); + var res : f16 = trunc(1.5h); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl index bbc6432ee9..33f08adfd3 100644 --- a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl +++ b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(vec<4, f16>) -> vec<4, f16> fn trunc_ce7c17() { - var res: vec4 = trunc(vec4(1.h)); + var res: vec4 = trunc(vec4(1.5h)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.dxc.hlsl index 3d1afee275..de7a7a1656 100644 --- a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_ce7c17() { - vector res = trunc((float16_t(1.0h)).xxxx); + vector res = (float16_t(1.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.glsl index 751a5a1681..58a3ba8857 100644 --- a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_ce7c17() { - f16vec4 res = trunc(f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void trunc_ce7c17() { - f16vec4 res = trunc(f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_ce7c17() { - f16vec4 res = trunc(f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.msl index 2676f2e2ff..b5e7109d6b 100644 --- a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_ce7c17() { - half4 res = trunc(half4(1.0h)); + half4 res = half4(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.spvasm index 67233c51c4..4e38066a12 100644 --- a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/ce7c17.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" @@ -38,37 +37,36 @@ %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 + %16 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %trunc_ce7c17 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Trunc %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 %trunc_ce7c17 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %trunc_ce7c17 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 %trunc_ce7c17 + %29 = OpLabel + %30 = OpFunctionCall %void %trunc_ce7c17 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %trunc_ce7c17 + %32 = OpLabel + %33 = OpFunctionCall %void %trunc_ce7c17 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.wgsl index 2f491edb30..4aa5e83b08 100644 --- a/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/ce7c17.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_ce7c17() { - var res : vec4 = trunc(vec4(1.0h)); + var res : vec4 = trunc(vec4(1.5h)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl index 5894d363b8..77ccdb2591 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl @@ -23,7 +23,7 @@ // fn trunc(vec<4, f32>) -> vec<4, f32> fn trunc_e183aa() { - var res: vec4 = trunc(vec4(1.f)); + var res: vec4 = trunc(vec4(1.5f)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.dxc.hlsl index a60a1323f1..a9a654764c 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_e183aa() { - float4 res = trunc((1.0f).xxxx); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.fxc.hlsl index a60a1323f1..a9a654764c 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_e183aa() { - float4 res = trunc((1.0f).xxxx); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.glsl index fe0ba3bed7..f820c16e6f 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_e183aa() { - vec4 res = trunc(vec4(1.0f)); + vec4 res = vec4(1.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void trunc_e183aa() { - vec4 res = trunc(vec4(1.0f)); + vec4 res = vec4(1.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void trunc_e183aa() { - vec4 res = trunc(vec4(1.0f)); + vec4 res = vec4(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.msl index 960dffdb99..b801d810e2 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_e183aa() { - float4 res = trunc(float4(1.0f)); + float4 res = float4(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.spvasm index 715c2a5863..5ed2379630 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; 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" @@ -32,35 +31,34 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float %trunc_e183aa = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Trunc %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %trunc_e183aa +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %trunc_e183aa 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 %trunc_e183aa + %25 = OpLabel + %26 = OpFunctionCall %void %trunc_e183aa OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %trunc_e183aa + %28 = OpLabel + %29 = OpFunctionCall %void %trunc_e183aa OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.wgsl index 00a29916f9..b3d734b4b3 100644 --- a/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/e183aa.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_e183aa() { - var res : vec4 = trunc(vec4(1.0f)); + var res : vec4 = trunc(vec4(1.5f)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl index 6634dda54e..9d3490fab9 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl @@ -23,7 +23,7 @@ // fn trunc(f32) -> f32 fn trunc_eb83df() { - var res: f32 = trunc(1.f); + var res: f32 = trunc(1.5f); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.dxc.hlsl index 082acc562d..a539009f73 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_eb83df() { - float res = trunc(1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.fxc.hlsl index 082acc562d..a539009f73 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_eb83df() { - float res = trunc(1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.glsl index d4b264e129..dbe86ab3ee 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_eb83df() { - float res = trunc(1.0f); + float res = 1.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void trunc_eb83df() { - float res = trunc(1.0f); + float res = 1.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void trunc_eb83df() { - float res = trunc(1.0f); + float res = 1.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.msl index 3498d6e681..da544f9178 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_eb83df() { - float res = trunc(1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.spvasm index 2152182a4a..42b2976b18 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 29 ; 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" @@ -33,33 +32,32 @@ %9 = OpTypeFunction %void %float_1 = OpConstant %float 1 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float %trunc_eb83df = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Trunc %float_1 - OpStore %res %13 + OpStore %res %float_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %trunc_eb83df +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %trunc_eb83df 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 %trunc_eb83df + %24 = OpLabel + %25 = OpFunctionCall %void %trunc_eb83df OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %trunc_eb83df + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_eb83df OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.wgsl index b1207fb551..b5f6d6efcd 100644 --- a/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/eb83df.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_eb83df() { - var res : f32 = trunc(1.0f); + var res : f32 = trunc(1.5f); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl new file mode 100644 index 0000000000..80c37aa32a --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.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 trunc(vec<4, fa>) -> vec<4, fa> +fn trunc_f0f1a1() { + var res = trunc(vec4(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_f0f1a1(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_f0f1a1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_f0f1a1(); +} diff --git a/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0db7616818 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_f0f1a1() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_f0f1a1(); + 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() { + trunc_f0f1a1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_f0f1a1(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0db7616818 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_f0f1a1() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_f0f1a1(); + 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() { + trunc_f0f1a1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_f0f1a1(); + return; +} diff --git a/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.glsl new file mode 100644 index 0000000000..b04c0144d4 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_f0f1a1() { + vec4 res = vec4(1.0f); +} + +vec4 vertex_main() { + trunc_f0f1a1(); + 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 trunc_f0f1a1() { + vec4 res = vec4(1.0f); +} + +void fragment_main() { + trunc_f0f1a1(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_f0f1a1() { + vec4 res = vec4(1.0f); +} + +void compute_main() { + trunc_f0f1a1(); +} + +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/trunc/f0f1a1.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.msl new file mode 100644 index 0000000000..d04242ec1c --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_f0f1a1() { + float4 res = float4(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_f0f1a1(); + 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() { + trunc_f0f1a1(); + return; +} + +kernel void compute_main() { + trunc_f0f1a1(); + return; +} + diff --git a/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.spvasm new file mode 100644 index 0000000000..c3281d5720 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.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 %trunc_f0f1a1 "trunc_f0f1a1" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float +%trunc_f0f1a1 = 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 %trunc_f0f1a1 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %trunc_f0f1a1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %trunc_f0f1a1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.wgsl new file mode 100644 index 0000000000..997dd99ba8 --- /dev/null +++ b/test/tint/builtins/gen/literal/trunc/f0f1a1.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn trunc_f0f1a1() { + var res = trunc(vec4(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_f0f1a1(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_f0f1a1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_f0f1a1(); +} diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl index a936cdf201..6853256247 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl @@ -23,7 +23,7 @@ // fn trunc(vec<2, f32>) -> vec<2, f32> fn trunc_f370d3() { - var res: vec2 = trunc(vec2(1.f)); + var res: vec2 = trunc(vec2(1.5f)); } @vertex diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.dxc.hlsl index 8e7b9d733b..76ca41a5eb 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_f370d3() { - float2 res = trunc((1.0f).xx); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.fxc.hlsl index 8e7b9d733b..76ca41a5eb 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_f370d3() { - float2 res = trunc((1.0f).xx); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.glsl index ff8b53fc62..1e4aaf97d6 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_f370d3() { - vec2 res = trunc(vec2(1.0f)); + vec2 res = vec2(1.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void trunc_f370d3() { - vec2 res = trunc(vec2(1.0f)); + vec2 res = vec2(1.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void trunc_f370d3() { - vec2 res = trunc(vec2(1.0f)); + vec2 res = vec2(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.msl b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.msl index ae71a0aaf3..ceac6e4468 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_f370d3() { - float2 res = trunc(float2(1.0f)); + float2 res = float2(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.spvasm index 07e4e38729..2f2f61a3ae 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; 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" @@ -33,36 +32,35 @@ %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 + %15 = OpConstantComposite %v2float %float_1 %float_1 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float %trunc_f370d3 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Trunc %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 %trunc_f370d3 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %trunc_f370d3 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 %trunc_f370d3 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_f370d3 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %trunc_f370d3 + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_f370d3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.wgsl index 75b84d8e41..8dad61f5a2 100644 --- a/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/trunc/f370d3.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_f370d3() { - var res : vec2 = trunc(vec2(1.0f)); + var res : vec2 = trunc(vec2(1.5f)); } @vertex diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl b/test/tint/builtins/gen/var/trunc/103ab8.wgsl index 09e2de388b..b1c2ecbc71 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl +++ b/test/tint/builtins/gen/var/trunc/103ab8.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(vec<3, f16>) -> vec<3, f16> fn trunc_103ab8() { - var arg_0 = vec3(1.h); + var arg_0 = vec3(1.5h); var res: vec3 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl index ddbd6d2139..8eb5c9110e 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_103ab8() { - vector arg_0 = (float16_t(1.0h)).xxx; + vector arg_0 = (float16_t(1.5h)).xxx; vector res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.glsl index ffb099ff39..bb2e9a70b2 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_103ab8() { - f16vec3 arg_0 = f16vec3(1.0hf); + f16vec3 arg_0 = f16vec3(1.5hf); f16vec3 res = trunc(arg_0); } @@ -24,7 +24,7 @@ void main() { precision mediump float; void trunc_103ab8() { - f16vec3 arg_0 = f16vec3(1.0hf); + f16vec3 arg_0 = f16vec3(1.5hf); f16vec3 res = trunc(arg_0); } @@ -40,7 +40,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_103ab8() { - f16vec3 arg_0 = f16vec3(1.0hf); + f16vec3 arg_0 = f16vec3(1.5hf); f16vec3 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.msl index 22056f0381..4e3f505200 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_103ab8() { - half3 arg_0 = half3(1.0h); + half3 arg_0 = half3(1.5h); half3 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.spvasm index 91192b4435..e6b9a38e48 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/103ab8.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_8p_0 = OpConstant %half 0x1.8p+0 + %16 = OpConstantComposite %v3half %half_0x1_8p_0 %half_0x1_8p_0 %half_0x1_8p_0 %_ptr_Function_v3half = OpTypePointer Function %v3half %19 = OpConstantNull %v3half %24 = OpTypeFunction %v4float diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.wgsl index dc42691710..8ccaf015fa 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_103ab8() { - var arg_0 = vec3(1.0h); + var arg_0 = vec3(1.5h); var res : vec3 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/117396.wgsl b/test/tint/builtins/gen/var/trunc/117396.wgsl new file mode 100644 index 0000000000..811ba780fa --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.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 trunc(vec<3, fa>) -> vec<3, fa> +fn trunc_117396() { + const arg_0 = vec3(1.5); + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_117396(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_117396(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_117396(); +} diff --git a/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..d3f4162f0d --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_117396() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_117396(); + 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() { + trunc_117396(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_117396(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..d3f4162f0d --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_117396() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_117396(); + 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() { + trunc_117396(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_117396(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.glsl new file mode 100644 index 0000000000..f81df1368d --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_117396() { + vec3 res = vec3(1.0f); +} + +vec4 vertex_main() { + trunc_117396(); + 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 trunc_117396() { + vec3 res = vec3(1.0f); +} + +void fragment_main() { + trunc_117396(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_117396() { + vec3 res = vec3(1.0f); +} + +void compute_main() { + trunc_117396(); +} + +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/trunc/117396.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.msl new file mode 100644 index 0000000000..0fb23c3b8a --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_117396() { + float3 res = float3(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_117396(); + 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() { + trunc_117396(); + return; +} + +kernel void compute_main() { + trunc_117396(); + return; +} + diff --git a/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.spvasm new file mode 100644 index 0000000000..9b9d61cec3 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %trunc_117396 "trunc_117396" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float +%trunc_117396 = 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 %trunc_117396 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_117396 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_117396 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.wgsl new file mode 100644 index 0000000000..39fdc96ea8 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/117396.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn trunc_117396() { + const arg_0 = vec3(1.5); + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_117396(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_117396(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_117396(); +} diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl index 14bc4a65b1..de79b2a8e4 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl @@ -23,7 +23,7 @@ // fn trunc(vec<3, f32>) -> vec<3, f32> fn trunc_562d05() { - var arg_0 = vec3(1.f); + var arg_0 = vec3(1.5f); var res: vec3 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl index 685ad83f10..bee4949322 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_562d05() { - float3 arg_0 = (1.0f).xxx; + float3 arg_0 = (1.5f).xxx; float3 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl index 685ad83f10..bee4949322 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_562d05() { - float3 arg_0 = (1.0f).xxx; + float3 arg_0 = (1.5f).xxx; float3 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.glsl index 7b2bc3cd7e..697c356ce9 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_562d05() { - vec3 arg_0 = vec3(1.0f); + vec3 arg_0 = vec3(1.5f); vec3 res = trunc(arg_0); } @@ -22,7 +22,7 @@ void main() { precision mediump float; void trunc_562d05() { - vec3 arg_0 = vec3(1.0f); + vec3 arg_0 = vec3(1.5f); vec3 res = trunc(arg_0); } @@ -37,7 +37,7 @@ void main() { #version 310 es void trunc_562d05() { - vec3 arg_0 = vec3(1.0f); + vec3 arg_0 = vec3(1.5f); vec3 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.msl index e5632e67dc..a81ade226c 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_562d05() { - float3 arg_0 = float3(1.0f); + float3 arg_0 = float3(1.5f); float3 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.spvasm index f5f52887b0..4985ca84ca 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/562d05.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_5 = OpConstant %float 1.5 + %15 = OpConstantComposite %v3float %float_1_5 %float_1_5 %float_1_5 %_ptr_Function_v3float = OpTypePointer Function %v3float %18 = OpConstantNull %v3float %23 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %trunc_562d05 = 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 %trunc_562d05 + %32 = OpLabel + %33 = OpFunctionCall %void %trunc_562d05 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %trunc_562d05 + %35 = OpLabel + %36 = OpFunctionCall %void %trunc_562d05 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.wgsl index f005830dc6..fce6311bf2 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_562d05() { - var arg_0 = vec3(1.0f); + var arg_0 = vec3(1.5f); var res : vec3 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/7d6ded.wgsl b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl new file mode 100644 index 0000000000..ef22069a8d --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.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 trunc(fa) -> fa +fn trunc_7d6ded() { + const arg_0 = 1.5; + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_7d6ded(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_7d6ded(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_7d6ded(); +} diff --git a/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..faba2f89cc --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_7d6ded() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_7d6ded(); + 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() { + trunc_7d6ded(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_7d6ded(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..faba2f89cc --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_7d6ded() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_7d6ded(); + 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() { + trunc_7d6ded(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_7d6ded(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.glsl new file mode 100644 index 0000000000..c25da0be76 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_7d6ded() { + float res = 1.0f; +} + +vec4 vertex_main() { + trunc_7d6ded(); + 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 trunc_7d6ded() { + float res = 1.0f; +} + +void fragment_main() { + trunc_7d6ded(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_7d6ded() { + float res = 1.0f; +} + +void compute_main() { + trunc_7d6ded(); +} + +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/trunc/7d6ded.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.msl new file mode 100644 index 0000000000..1bf5a61e77 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_7d6ded() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_7d6ded(); + 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() { + trunc_7d6ded(); + return; +} + +kernel void compute_main() { + trunc_7d6ded(); + return; +} + diff --git a/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.spvasm new file mode 100644 index 0000000000..0b3118bfa6 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.spvasm @@ -0,0 +1,63 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 29 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %trunc_7d6ded "trunc_7d6ded" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float +%trunc_7d6ded = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %trunc_7d6ded + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %trunc_7d6ded + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_7d6ded + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.wgsl new file mode 100644 index 0000000000..e4cfb9c525 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/7d6ded.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn trunc_7d6ded() { + const arg_0 = 1.5; + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_7d6ded(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_7d6ded(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_7d6ded(); +} diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl b/test/tint/builtins/gen/var/trunc/a56109.wgsl index 4e6b5b1dc8..b7604e3b74 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl +++ b/test/tint/builtins/gen/var/trunc/a56109.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(vec<2, f16>) -> vec<2, f16> fn trunc_a56109() { - var arg_0 = vec2(1.h); + var arg_0 = vec2(1.5h); var res: vec2 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl index 059dfcf7b6..64f93d2e45 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_a56109() { - vector arg_0 = (float16_t(1.0h)).xx; + vector arg_0 = (float16_t(1.5h)).xx; vector res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.glsl index 3855c86497..5e8431c9dc 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_a56109() { - f16vec2 arg_0 = f16vec2(1.0hf); + f16vec2 arg_0 = f16vec2(1.5hf); f16vec2 res = trunc(arg_0); } @@ -24,7 +24,7 @@ void main() { precision mediump float; void trunc_a56109() { - f16vec2 arg_0 = f16vec2(1.0hf); + f16vec2 arg_0 = f16vec2(1.5hf); f16vec2 res = trunc(arg_0); } @@ -40,7 +40,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_a56109() { - f16vec2 arg_0 = f16vec2(1.0hf); + f16vec2 arg_0 = f16vec2(1.5hf); f16vec2 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.msl index 38660ec486..0ee977d5f3 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_a56109() { - half2 arg_0 = half2(1.0h); + half2 arg_0 = half2(1.5h); half2 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.spvasm index c7d09416d2..c9553ad4c5 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/a56109.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_8p_0 = OpConstant %half 0x1.8p+0 + %16 = OpConstantComposite %v2half %half_0x1_8p_0 %half_0x1_8p_0 %_ptr_Function_v2half = OpTypePointer Function %v2half %19 = OpConstantNull %v2half %24 = OpTypeFunction %v4float diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.wgsl index 71aabc5af3..e22e108632 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_a56109() { - var arg_0 = vec2(1.0h); + var arg_0 = vec2(1.5h); var res : vec2 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/c12555.wgsl b/test/tint/builtins/gen/var/trunc/c12555.wgsl new file mode 100644 index 0000000000..709141557a --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.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 trunc(vec<2, fa>) -> vec<2, fa> +fn trunc_c12555() { + const arg_0 = vec2(1.5); + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_c12555(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_c12555(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_c12555(); +} diff --git a/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..bb9d35f671 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_c12555() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_c12555(); + 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() { + trunc_c12555(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_c12555(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..bb9d35f671 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_c12555() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_c12555(); + 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() { + trunc_c12555(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_c12555(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.glsl new file mode 100644 index 0000000000..bcd6a46cbb --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_c12555() { + vec2 res = vec2(1.0f); +} + +vec4 vertex_main() { + trunc_c12555(); + 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 trunc_c12555() { + vec2 res = vec2(1.0f); +} + +void fragment_main() { + trunc_c12555(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_c12555() { + vec2 res = vec2(1.0f); +} + +void compute_main() { + trunc_c12555(); +} + +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/trunc/c12555.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.msl new file mode 100644 index 0000000000..0a7ef276c0 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_c12555() { + float2 res = float2(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_c12555(); + 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() { + trunc_c12555(); + return; +} + +kernel void compute_main() { + trunc_c12555(); + return; +} + diff --git a/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.spvasm new file mode 100644 index 0000000000..5b3cd3a7df --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %trunc_c12555 "trunc_c12555" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v2float %float_1 %float_1 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float +%trunc_c12555 = 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 %trunc_c12555 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %trunc_c12555 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_c12555 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.wgsl new file mode 100644 index 0000000000..069e7cdad5 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/c12555.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn trunc_c12555() { + const arg_0 = vec2(1.5); + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_c12555(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_c12555(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_c12555(); +} diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl index ee4f839c68..8af04dde7f 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(f16) -> f16 fn trunc_cc2b0d() { - var arg_0 = 1.h; + var arg_0 = 1.5h; var res: f16 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl index 8f1a6afef6..6c318d032d 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_cc2b0d() { - float16_t arg_0 = float16_t(1.0h); + float16_t arg_0 = float16_t(1.5h); float16_t res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.glsl index f0e9d9cde4..fa17dcb716 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_cc2b0d() { - float16_t arg_0 = 1.0hf; + float16_t arg_0 = 1.5hf; float16_t res = trunc(arg_0); } @@ -24,7 +24,7 @@ void main() { precision mediump float; void trunc_cc2b0d() { - float16_t arg_0 = 1.0hf; + float16_t arg_0 = 1.5hf; float16_t res = trunc(arg_0); } @@ -40,7 +40,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_cc2b0d() { - float16_t arg_0 = 1.0hf; + float16_t arg_0 = 1.5hf; float16_t res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.msl index 25fd8e19d8..77638e317e 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_cc2b0d() { - half arg_0 = 1.0h; + half arg_0 = 1.5h; half res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.spvasm index 1266beb6e0..9c8859b766 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.spvasm @@ -37,7 +37,7 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 +%half_0x1_8p_0 = OpConstant %half 0x1.8p+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_8p_0 %20 = OpLoad %half %arg_0 %18 = OpExtInst %half %19 Trunc %20 OpStore %res %18 diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.wgsl index cc68f295cd..f943aa75a1 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_cc2b0d() { - var arg_0 = 1.0h; + var arg_0 = 1.5h; var res : f16 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl index be36c021da..06955c358d 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl +++ b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl @@ -25,7 +25,7 @@ enable f16; // fn trunc(vec<4, f16>) -> vec<4, f16> fn trunc_ce7c17() { - var arg_0 = vec4(1.h); + var arg_0 = vec4(1.5h); var res: vec4 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl index fedd729c03..adfdbc221f 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_ce7c17() { - vector arg_0 = (float16_t(1.0h)).xxxx; + vector arg_0 = (float16_t(1.5h)).xxxx; vector res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.glsl index 6b65996bbf..f1fca58b8f 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void trunc_ce7c17() { - f16vec4 arg_0 = f16vec4(1.0hf); + f16vec4 arg_0 = f16vec4(1.5hf); f16vec4 res = trunc(arg_0); } @@ -24,7 +24,7 @@ void main() { precision mediump float; void trunc_ce7c17() { - f16vec4 arg_0 = f16vec4(1.0hf); + f16vec4 arg_0 = f16vec4(1.5hf); f16vec4 res = trunc(arg_0); } @@ -40,7 +40,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void trunc_ce7c17() { - f16vec4 arg_0 = f16vec4(1.0hf); + f16vec4 arg_0 = f16vec4(1.5hf); f16vec4 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.msl index f3f90c4aed..b5e9d81763 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_ce7c17() { - half4 arg_0 = half4(1.0h); + half4 arg_0 = half4(1.5h); half4 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.spvasm index 91cad17725..f8e77e7b91 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/ce7c17.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_8p_0 = OpConstant %half 0x1.8p+0 + %16 = OpConstantComposite %v4half %half_0x1_8p_0 %half_0x1_8p_0 %half_0x1_8p_0 %half_0x1_8p_0 %_ptr_Function_v4half = OpTypePointer Function %v4half %19 = OpConstantNull %v4half %24 = OpTypeFunction %v4float diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.wgsl index 8fa5b3b2b5..bdf34ffb38 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.wgsl @@ -1,7 +1,7 @@ enable f16; fn trunc_ce7c17() { - var arg_0 = vec4(1.0h); + var arg_0 = vec4(1.5h); var res : vec4 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl index c21a06b99e..b3cab104e7 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl @@ -23,7 +23,7 @@ // fn trunc(vec<4, f32>) -> vec<4, f32> fn trunc_e183aa() { - var arg_0 = vec4(1.f); + var arg_0 = vec4(1.5f); var res: vec4 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl index 10af761992..86604bdc8e 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_e183aa() { - float4 arg_0 = (1.0f).xxxx; + float4 arg_0 = (1.5f).xxxx; float4 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl index 10af761992..86604bdc8e 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_e183aa() { - float4 arg_0 = (1.0f).xxxx; + float4 arg_0 = (1.5f).xxxx; float4 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.glsl index efb9d97035..abed6a6ebd 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_e183aa() { - vec4 arg_0 = vec4(1.0f); + vec4 arg_0 = vec4(1.5f); vec4 res = trunc(arg_0); } @@ -22,7 +22,7 @@ void main() { precision mediump float; void trunc_e183aa() { - vec4 arg_0 = vec4(1.0f); + vec4 arg_0 = vec4(1.5f); vec4 res = trunc(arg_0); } @@ -37,7 +37,7 @@ void main() { #version 310 es void trunc_e183aa() { - vec4 arg_0 = vec4(1.0f); + vec4 arg_0 = vec4(1.5f); vec4 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.msl index 4820d6cb84..4e3992b3c0 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_e183aa() { - float4 arg_0 = float4(1.0f); + float4 arg_0 = float4(1.5f); float4 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.spvasm index 565159a506..bfc9dd8bd4 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/e183aa.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_5 = OpConstant %float 1.5 + %14 = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5 %_ptr_Function_v4float = OpTypePointer Function %v4float %21 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %trunc_e183aa = 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 %trunc_e183aa + %30 = OpLabel + %31 = OpFunctionCall %void %trunc_e183aa OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %trunc_e183aa + %33 = OpLabel + %34 = OpFunctionCall %void %trunc_e183aa OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.wgsl index f1f1db3af4..3aba18f7db 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_e183aa() { - var arg_0 = vec4(1.0f); + var arg_0 = vec4(1.5f); var res : vec4 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl index 8ac0bdba26..5ea7bcd058 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl @@ -23,7 +23,7 @@ // fn trunc(f32) -> f32 fn trunc_eb83df() { - var arg_0 = 1.f; + var arg_0 = 1.5f; var res: f32 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl index 7f13d9aa9c..1056d4fd02 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_eb83df() { - float arg_0 = 1.0f; + float arg_0 = 1.5f; float res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl index 7f13d9aa9c..1056d4fd02 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_eb83df() { - float arg_0 = 1.0f; + float arg_0 = 1.5f; float res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.glsl index 57e9bd8e22..2baaf2d0d6 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_eb83df() { - float arg_0 = 1.0f; + float arg_0 = 1.5f; float res = trunc(arg_0); } @@ -22,7 +22,7 @@ void main() { precision mediump float; void trunc_eb83df() { - float arg_0 = 1.0f; + float arg_0 = 1.5f; float res = trunc(arg_0); } @@ -37,7 +37,7 @@ void main() { #version 310 es void trunc_eb83df() { - float arg_0 = 1.0f; + float arg_0 = 1.5f; float res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.msl index 2408d6cc46..1f4dab6891 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_eb83df() { - float arg_0 = 1.0f; + float arg_0 = 1.5f; float res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.spvasm index f5fa2a263e..15a7d6d4d9 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/eb83df.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_5 = OpConstant %float 1.5 %_ptr_Function_float = OpTypePointer Function %float %20 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %trunc_eb83df = 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_5 %18 = OpLoad %float %arg_0 %16 = OpExtInst %float %17 Trunc %18 OpStore %res %16 @@ -58,12 +59,12 @@ OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %void %trunc_eb83df + %29 = OpLabel + %30 = OpFunctionCall %void %trunc_eb83df OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %trunc_eb83df + %32 = OpLabel + %33 = OpFunctionCall %void %trunc_eb83df OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.wgsl index ae1518f18a..6cb3f547f1 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_eb83df() { - var arg_0 = 1.0f; + var arg_0 = 1.5f; var res : f32 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl new file mode 100644 index 0000000000..720789cf10 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.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 trunc(vec<4, fa>) -> vec<4, fa> +fn trunc_f0f1a1() { + const arg_0 = vec4(1.5); + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_f0f1a1(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_f0f1a1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_f0f1a1(); +} diff --git a/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0db7616818 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void trunc_f0f1a1() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_f0f1a1(); + 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() { + trunc_f0f1a1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_f0f1a1(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0db7616818 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void trunc_f0f1a1() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + trunc_f0f1a1(); + 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() { + trunc_f0f1a1(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + trunc_f0f1a1(); + return; +} diff --git a/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.glsl new file mode 100644 index 0000000000..b04c0144d4 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void trunc_f0f1a1() { + vec4 res = vec4(1.0f); +} + +vec4 vertex_main() { + trunc_f0f1a1(); + 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 trunc_f0f1a1() { + vec4 res = vec4(1.0f); +} + +void fragment_main() { + trunc_f0f1a1(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void trunc_f0f1a1() { + vec4 res = vec4(1.0f); +} + +void compute_main() { + trunc_f0f1a1(); +} + +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/trunc/f0f1a1.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.msl new file mode 100644 index 0000000000..d04242ec1c --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void trunc_f0f1a1() { + float4 res = float4(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + trunc_f0f1a1(); + 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() { + trunc_f0f1a1(); + return; +} + +kernel void compute_main() { + trunc_f0f1a1(); + return; +} + diff --git a/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.spvasm new file mode 100644 index 0000000000..c3281d5720 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.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 %trunc_f0f1a1 "trunc_f0f1a1" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float +%trunc_f0f1a1 = 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 %trunc_f0f1a1 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %trunc_f0f1a1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %trunc_f0f1a1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.wgsl new file mode 100644 index 0000000000..3166920977 --- /dev/null +++ b/test/tint/builtins/gen/var/trunc/f0f1a1.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn trunc_f0f1a1() { + const arg_0 = vec4(1.5); + var res = trunc(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + trunc_f0f1a1(); + return vec4(); +} + +@fragment +fn fragment_main() { + trunc_f0f1a1(); +} + +@compute @workgroup_size(1) +fn compute_main() { + trunc_f0f1a1(); +} diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl index 79159564f9..843d598792 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl @@ -23,7 +23,7 @@ // fn trunc(vec<2, f32>) -> vec<2, f32> fn trunc_f370d3() { - var arg_0 = vec2(1.f); + var arg_0 = vec2(1.5f); var res: vec2 = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl index 5f59f24583..4763fd825b 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void trunc_f370d3() { - float2 arg_0 = (1.0f).xx; + float2 arg_0 = (1.5f).xx; float2 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl index 5f59f24583..4763fd825b 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void trunc_f370d3() { - float2 arg_0 = (1.0f).xx; + float2 arg_0 = (1.5f).xx; float2 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.glsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.glsl index a850df2896..9ab35b5721 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void trunc_f370d3() { - vec2 arg_0 = vec2(1.0f); + vec2 arg_0 = vec2(1.5f); vec2 res = trunc(arg_0); } @@ -22,7 +22,7 @@ void main() { precision mediump float; void trunc_f370d3() { - vec2 arg_0 = vec2(1.0f); + vec2 arg_0 = vec2(1.5f); vec2 res = trunc(arg_0); } @@ -37,7 +37,7 @@ void main() { #version 310 es void trunc_f370d3() { - vec2 arg_0 = vec2(1.0f); + vec2 arg_0 = vec2(1.5f); vec2 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.msl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.msl index fdce7c2238..074922c180 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void trunc_f370d3() { - float2 arg_0 = float2(1.0f); + float2 arg_0 = float2(1.5f); float2 res = trunc(arg_0); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.spvasm b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.spvasm index 3736cd6243..917f79ea5c 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/trunc/f370d3.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_5 = OpConstant %float 1.5 + %15 = OpConstantComposite %v2float %float_1_5 %float_1_5 %_ptr_Function_v2float = OpTypePointer Function %v2float %18 = OpConstantNull %v2float %23 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %trunc_f370d3 = 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 %trunc_f370d3 + %32 = OpLabel + %33 = OpFunctionCall %void %trunc_f370d3 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %trunc_f370d3 + %35 = OpLabel + %36 = OpFunctionCall %void %trunc_f370d3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.wgsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.wgsl index 537761fb75..5fe9aac1fd 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn trunc_f370d3() { - var arg_0 = vec2(1.0f); + var arg_0 = vec2(1.5f); var res : vec2 = trunc(arg_0); }