diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 7d81bf9f65..9b429198d7 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -493,10 +493,10 @@ fn ldexp(T, i32) -> T fn ldexp(vec, vec) -> vec @const fn length(@test_value(0.0) T) -> T @const fn length(@test_value(0.0) vec) -> T -fn log(T) -> T -fn log(vec) -> vec -fn log2(T) -> T -fn log2(vec) -> vec +@const fn log(T) -> T +@const fn log(vec) -> vec +@const fn log2(T) -> T +@const fn log2(vec) -> vec @const fn max(T, T) -> T @const fn max(vec, vec) -> vec @const fn min(T, T) -> T diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc index 675ff495ad..c0452cedea 100644 --- a/src/tint/resolver/builtins_validation_test.cc +++ b/src/tint/resolver/builtins_validation_test.cc @@ -1099,7 +1099,7 @@ TEST_P(FloatAllMatching, Scalar) { utils::Vector params; for (uint32_t i = 0; i < num_params; ++i) { - params.Push(Expr(f32(i))); + params.Push(Expr(f32(i + 1))); } auto* builtin = Call(name, params); Func("func", utils::Empty, ty.void_(), @@ -1120,7 +1120,7 @@ TEST_P(FloatAllMatching, Vec2) { utils::Vector params; for (uint32_t i = 0; i < num_params; ++i) { - params.Push(vec2(f32(i), f32(i))); + params.Push(vec2(f32(i + 1), f32(i + 1))); } auto* builtin = Call(name, params); Func("func", utils::Empty, ty.void_(), @@ -1141,7 +1141,7 @@ TEST_P(FloatAllMatching, Vec3) { utils::Vector params; for (uint32_t i = 0; i < num_params; ++i) { - params.Push(vec3(f32(i), f32(i), f32(i))); + params.Push(vec3(f32(i + 1), f32(i + 1), f32(i + 1))); } auto* builtin = Call(name, params); Func("func", utils::Empty, ty.void_(), @@ -1162,7 +1162,7 @@ TEST_P(FloatAllMatching, Vec4) { utils::Vector params; for (uint32_t i = 0; i < num_params; ++i) { - params.Push(vec4(f32(i), f32(i), f32(i), f32(i))); + params.Push(vec4(f32(i + 1), f32(i + 1), f32(i + 1), f32(i + 1))); } auto* builtin = Call(name, params); Func("func", utils::Empty, ty.void_(), diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index f3cbc9d9e7..4b365fe770 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -2300,6 +2300,40 @@ ConstEval::Result ConstEval::length(const sem::Type* ty, return r; } +ConstEval::Result ConstEval::log(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto v) -> ImplResult { + using NumberT = decltype(v); + if (v <= NumberT(0)) { + AddError("log must be called with a value > 0", source); + return utils::Failure; + } + return CreateElement(builder, source, c0->Type(), NumberT(std::log(v))); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + +ConstEval::Result ConstEval::log2(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto v) -> ImplResult { + using NumberT = decltype(v); + if (v <= NumberT(0)) { + AddError("log2 must be called with a value > 0", source); + return utils::Failure; + } + return CreateElement(builder, source, c0->Type(), NumberT(std::log2(v))); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::max(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 2f2edc49f2..4b3bb5405f 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -628,6 +628,24 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// log builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location + /// @return the result value, or null if the value cannot be calculated + Result log(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + + /// log2 builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location + /// @return the result value, or null if the value cannot be calculated + Result log2(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// max 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 fe587ffcbe..70a5bc82d5 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1296,6 +1296,110 @@ INSTANTIATE_TEST_SUITE_P( // LengthCases(), LengthCases())))); +template +std::vector LogCases() { + auto error_msg = [] { return "12:34 error: log must be called with a value > 0"; }; + return std::vector{C({T(1)}, T(0)), // + C({T(54.598150033)}, T(4)).FloatComp(0.002), // + + E({T::Lowest()}, error_msg()), E({T(0)}, error_msg()), + E({-T(0)}, error_msg())}; +} +INSTANTIATE_TEST_SUITE_P( // + Log, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog), + testing::ValuesIn(Concat(LogCases(), // + LogCases(), + LogCases())))); +template +std::vector LogF16Cases() { + return std::vector{ + C({T::Highest()}, T(11.085938)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + LogF16, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog), + testing::ValuesIn(LogF16Cases()))); +template +std::vector LogF32Cases() { + return std::vector{ + C({T::Highest()}, T(88.722839)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + LogF32, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog), + testing::ValuesIn(LogF32Cases()))); + +template +std::vector LogAbstractCases() { + return std::vector{ + C({T::Highest()}, T(709.78271)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + LogAbstract, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog), + testing::ValuesIn(LogAbstractCases()))); + +template +std::vector Log2Cases() { + auto error_msg = [] { return "12:34 error: log2 must be called with a value > 0"; }; + return std::vector{ + C({T(1)}, T(0)), // + C({T(4)}, T(2)), // + + E({T::Lowest()}, error_msg()), + E({T(0)}, error_msg()), + E({-T(0)}, error_msg()), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Log2, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog2), + testing::ValuesIn(Concat(Log2Cases(), // + Log2Cases(), + Log2Cases())))); +template +std::vector Log2F16Cases() { + return std::vector{ + C({T::Highest()}, T(15.9922)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Log2F16, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog2), + testing::ValuesIn(Log2F16Cases()))); +template +std::vector Log2F32Cases() { + return std::vector{ + C({T::Highest()}, T(128)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Log2F32, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog2), + testing::ValuesIn(Log2F32Cases()))); +template +std::vector Log2AbstractCases() { + return std::vector{ + C({T::Highest()}, T(1024)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Log2Abstract, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kLog2), + testing::ValuesIn(Log2AbstractCases()))); + template std::vector MaxCases() { return { diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 74f377c4e9..1c54749f2f 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12750,48 +12750,48 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[874], /* return matcher indices */ &kMatcherIndices[3], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::log, }, { /* [370] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[875], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::log, }, { /* [371] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[876], /* return matcher indices */ &kMatcherIndices[3], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::log2, }, { /* [372] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[877], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::log2, }, { /* [373] */ @@ -14315,15 +14315,15 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [48] */ - /* fn log(T) -> T */ - /* fn log(vec) -> vec */ + /* fn log(T) -> T */ + /* fn log(vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[369], }, { /* [49] */ - /* fn log2(T) -> T */ - /* fn log2(vec) -> vec */ + /* fn log2(T) -> T */ + /* fn log2(vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[371], }, diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl index c0c3c6d1a3..8893465752 100644 --- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_3da25a() { - float4 res = log((1.0f).xxxx); + float4 res = (0.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl index c0c3c6d1a3..8893465752 100644 --- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log_3da25a() { - float4 res = log((1.0f).xxxx); + float4 res = (0.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl index df5ca13d23..fe9111475d 100644 --- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log_3da25a() { - vec4 res = log(vec4(1.0f)); + vec4 res = vec4(0.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log_3da25a() { - vec4 res = log(vec4(1.0f)); + vec4 res = vec4(0.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log_3da25a() { - vec4 res = log(vec4(1.0f)); + vec4 res = vec4(0.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl index dc18bb99d5..e70b8f9dc7 100644 --- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_3da25a() { - float4 res = log(float4(1.0f)); + float4 res = float4(0.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm index 65cc0302d1..0966583e29 100644 --- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; 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" @@ -31,36 +30,34 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log_3da25a = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Log %16 - OpStore %res %13 + OpStore %res %5 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %log_3da25a +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log_3da25a OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log_3da25a + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %27 = OpLabel %28 = OpFunctionCall %void %log_3da25a OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %log_3da25a - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl b/test/tint/builtins/gen/literal/log/655989.wgsl new file mode 100644 index 0000000000..4d2b2332b7 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.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 log(fa) -> fa +fn log_655989() { + var res = log(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_655989(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_655989(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_655989(); +} diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a8475f8637 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_655989() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_655989(); + 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() { + log_655989(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_655989(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a8475f8637 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_655989() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_655989(); + 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() { + log_655989(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_655989(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.glsl new file mode 100644 index 0000000000..e6a0182ca7 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_655989() { + float res = 0.0f; +} + +vec4 vertex_main() { + log_655989(); + 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 log_655989() { + float res = 0.0f; +} + +void fragment_main() { + log_655989(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_655989() { + float res = 0.0f; +} + +void compute_main() { + log_655989(); +} + +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/log/655989.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.msl new file mode 100644 index 0000000000..0b174b7d37 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_655989() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_655989(); + 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() { + log_655989(); + return; +} + +kernel void compute_main() { + log_655989(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.spvasm new file mode 100644 index 0000000000..6d7f01bb20 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.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 %log_655989 "log_655989" + 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 +%_ptr_Function_float = OpTypePointer Function %float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_655989 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %8 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log_655989 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log_655989 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log_655989 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.wgsl new file mode 100644 index 0000000000..2b2d5a9dc3 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log_655989() { + var res = log(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_655989(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_655989(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_655989(); +} diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl new file mode 100644 index 0000000000..20086fb5e4 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.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 log(vec<4, fa>) -> vec<4, fa> +fn log_697e1d() { + var res = log(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_697e1d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_697e1d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_697e1d(); +} diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..56bdd4cf08 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_697e1d() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_697e1d(); + 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() { + log_697e1d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_697e1d(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..56bdd4cf08 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_697e1d() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_697e1d(); + 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() { + log_697e1d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_697e1d(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.glsl new file mode 100644 index 0000000000..06b9a1b219 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_697e1d() { + vec4 res = vec4(0.0f); +} + +vec4 vertex_main() { + log_697e1d(); + 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 log_697e1d() { + vec4 res = vec4(0.0f); +} + +void fragment_main() { + log_697e1d(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_697e1d() { + vec4 res = vec4(0.0f); +} + +void compute_main() { + log_697e1d(); +} + +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/log/697e1d.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.msl new file mode 100644 index 0000000000..c3311d430e --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_697e1d() { + float4 res = float4(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_697e1d(); + 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() { + log_697e1d(); + return; +} + +kernel void compute_main() { + log_697e1d(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.spvasm new file mode 100644 index 0000000000..743229611a --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.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 %log_697e1d "log_697e1d" + 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 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_697e1d = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %5 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log_697e1d + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log_697e1d + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log_697e1d + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.wgsl new file mode 100644 index 0000000000..f4d96da6af --- /dev/null +++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log_697e1d() { + var res = log(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_697e1d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_697e1d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_697e1d(); +} diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl index 8d17f97c90..f53703347d 100644 --- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_6ff86f() { - vector res = log((float16_t(1.0h)).xxx); + vector res = (float16_t(0.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl index 5efd1c36b1..9fc5abc137 100644 --- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log_6ff86f() { - f16vec3 res = log(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log_6ff86f() { - f16vec3 res = log(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log_6ff86f() { - f16vec3 res = log(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl index 5b4c5318e1..f16f293762 100644 --- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_6ff86f() { - half3 res = log(half3(1.0h)); + half3 res = half3(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm index 2579458c21..bfd79740da 100644 --- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,35 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 + %15 = OpConstantNull %v3half %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log_6ff86f = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Log %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %15 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %log_6ff86f +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %log_6ff86f OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %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 - %31 = OpLabel - %32 = OpFunctionCall %void %log_6ff86f + %27 = OpLabel + %28 = OpFunctionCall %void %log_6ff86f OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %log_6ff86f + %30 = OpLabel + %31 = OpFunctionCall %void %log_6ff86f OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl index 8b9a62b68d..487519947a 100644 --- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_7114a6() { - float res = log(1.0f); + float res = 0.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl index 8b9a62b68d..487519947a 100644 --- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log_7114a6() { - float res = log(1.0f); + float res = 0.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl index 0c5e7ea612..6e2be1a80b 100644 --- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log_7114a6() { - float res = log(1.0f); + float res = 0.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log_7114a6() { - float res = log(1.0f); + float res = 0.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log_7114a6() { - float res = log(1.0f); + float res = 0.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl index 72da25e697..6f3b9c4ba5 100644 --- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_7114a6() { - float res = log(1.0f); + float res = 0.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm index 6d8292f5e8..17e7f0db49 100644 --- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/7114a6.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" @@ -31,35 +30,34 @@ %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 - %18 = OpTypeFunction %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log_7114a6 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Log %float_1 - OpStore %res %13 + OpStore %res %8 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %log_7114a6 +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log_7114a6 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %log_7114a6 + %24 = OpLabel + %25 = OpFunctionCall %void %log_7114a6 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %log_7114a6 + %27 = OpLabel + %28 = OpFunctionCall %void %log_7114a6 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl index eebe64c5ab..ef49c8f38e 100644 --- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_8f0e32() { - vector res = log((float16_t(1.0h)).xx); + vector res = (float16_t(0.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl index b75bf0d72b..b5dd01d41c 100644 --- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log_8f0e32() { - f16vec2 res = log(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log_8f0e32() { - f16vec2 res = log(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log_8f0e32() { - f16vec2 res = log(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl index 2d487405c8..33d2dabd5b 100644 --- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_8f0e32() { - half2 res = log(half2(1.0h)); + half2 res = half2(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm index 2a6e43203b..5960ad5e3d 100644 --- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,35 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 + %15 = OpConstantNull %v2half %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log_8f0e32 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Log %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %15 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %log_8f0e32 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %log_8f0e32 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %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 - %31 = OpLabel - %32 = OpFunctionCall %void %log_8f0e32 + %27 = OpLabel + %28 = OpFunctionCall %void %log_8f0e32 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %log_8f0e32 + %30 = OpLabel + %31 = OpFunctionCall %void %log_8f0e32 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl index 3eff95a367..200c1993fb 100644 --- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_b2ce28() { - float2 res = log((1.0f).xx); + float2 res = (0.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl index 3eff95a367..200c1993fb 100644 --- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log_b2ce28() { - float2 res = log((1.0f).xx); + float2 res = (0.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl index cc98643daa..223eccdf35 100644 --- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log_b2ce28() { - vec2 res = log(vec2(1.0f)); + vec2 res = vec2(0.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log_b2ce28() { - vec2 res = log(vec2(1.0f)); + vec2 res = vec2(0.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log_b2ce28() { - vec2 res = log(vec2(1.0f)); + vec2 res = vec2(0.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl index f9c13bd73f..9f693c49b3 100644 --- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_b2ce28() { - float2 res = log(float2(1.0f)); + float2 res = float2(0.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm index 5ea25fd7c2..fc4c327460 100644 --- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 31 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,35 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 + %14 = OpConstantNull %v2float %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log_b2ce28 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Log %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %14 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %log_b2ce28 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_b2ce28 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_b2ce28 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %29 = OpLabel %30 = OpFunctionCall %void %log_b2ce28 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %log_b2ce28 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl new file mode 100644 index 0000000000..f110dec8b9 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.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 log(vec<3, fa>) -> vec<3, fa> +fn log_b8088d() { + var res = log(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_b8088d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_b8088d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_b8088d(); +} diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0234c1d83c --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_b8088d() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_b8088d(); + 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() { + log_b8088d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_b8088d(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0234c1d83c --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_b8088d() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_b8088d(); + 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() { + log_b8088d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_b8088d(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.glsl new file mode 100644 index 0000000000..5dc623a06b --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_b8088d() { + vec3 res = vec3(0.0f); +} + +vec4 vertex_main() { + log_b8088d(); + 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 log_b8088d() { + vec3 res = vec3(0.0f); +} + +void fragment_main() { + log_b8088d(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_b8088d() { + vec3 res = vec3(0.0f); +} + +void compute_main() { + log_b8088d(); +} + +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/log/b8088d.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.msl new file mode 100644 index 0000000000..92066b0a75 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_b8088d() { + float3 res = float3(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_b8088d(); + 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() { + log_b8088d(); + return; +} + +kernel void compute_main() { + log_b8088d(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.spvasm new file mode 100644 index 0000000000..ed2010a743 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log_b8088d "log_b8088d" + 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 + %14 = OpConstantNull %v3float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_b8088d = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_b8088d + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_b8088d + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log_b8088d + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.wgsl new file mode 100644 index 0000000000..977c78cda9 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log_b8088d() { + var res = log(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_b8088d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_b8088d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_b8088d(); +} diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl index 358ac77db3..2102cac7f9 100644 --- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_c9f489() { - float16_t res = log(float16_t(1.0h)); + float16_t res = float16_t(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl index 2ae51ee837..c632da4a5f 100644 --- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log_c9f489() { - float16_t res = log(1.0hf); + float16_t res = 0.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log_c9f489() { - float16_t res = log(1.0hf); + float16_t res = 0.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log_c9f489() { - float16_t res = log(1.0hf); + float16_t res = 0.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl index cae5ee09be..a879c66c06 100644 --- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_c9f489() { - half res = log(1.0h); + half res = 0.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm index ddf328ccac..f056297c8f 100644 --- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 31 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -36,37 +35,35 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 + %14 = OpConstantNull %half %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log_c9f489 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Log %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %14 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %log_c9f489 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_c9f489 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_c9f489 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %29 = OpLabel %30 = OpFunctionCall %void %log_c9f489 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %log_c9f489 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl index 0ce91e544b..63f6f0ce5b 100644 --- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_cdbdc1() { - vector res = log((float16_t(1.0h)).xxxx); + vector res = (float16_t(0.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl index 272fe40188..5533178d4e 100644 --- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log_cdbdc1() { - f16vec4 res = log(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log_cdbdc1() { - f16vec4 res = log(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log_cdbdc1() { - f16vec4 res = log(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl index 7463bebd0f..49a8c75baf 100644 --- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_cdbdc1() { - half4 res = log(half4(1.0h)); + half4 res = half4(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm index a8a48f1168..29db7fceae 100644 --- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,35 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 + %15 = OpConstantNull %v4half %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log_cdbdc1 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Log %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %15 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %log_cdbdc1 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %log_cdbdc1 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %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 - %31 = OpLabel - %32 = OpFunctionCall %void %log_cdbdc1 + %27 = OpLabel + %28 = OpFunctionCall %void %log_cdbdc1 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %log_cdbdc1 + %30 = OpLabel + %31 = OpFunctionCall %void %log_cdbdc1 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl index 28d545b076..1a945273de 100644 --- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log_f4c570() { - float3 res = log((1.0f).xxx); + float3 res = (0.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl index 28d545b076..1a945273de 100644 --- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log_f4c570() { - float3 res = log((1.0f).xxx); + float3 res = (0.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl index 6a8af4433b..2537bba4e2 100644 --- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log_f4c570() { - vec3 res = log(vec3(1.0f)); + vec3 res = vec3(0.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log_f4c570() { - vec3 res = log(vec3(1.0f)); + vec3 res = vec3(0.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log_f4c570() { - vec3 res = log(vec3(1.0f)); + vec3 res = vec3(0.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl index 7f61e97137..afa767240d 100644 --- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log_f4c570() { - float3 res = log(float3(1.0f)); + float3 res = float3(0.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm index c0d6533d6a..799dd6401a 100644 --- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 31 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,35 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %14 = OpConstantNull %v3float %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log_f4c570 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Log %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %14 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %log_f4c570 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_f4c570 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_f4c570 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %29 = OpLabel %30 = OpFunctionCall %void %log_f4c570 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %log_f4c570 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl new file mode 100644 index 0000000000..971c4e12b1 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.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 log(vec<2, fa>) -> vec<2, fa> +fn log_f60cc7() { + var res = log(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_f60cc7(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_f60cc7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_f60cc7(); +} diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..41dbc64b8e --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_f60cc7() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_f60cc7(); + 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() { + log_f60cc7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_f60cc7(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..41dbc64b8e --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_f60cc7() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_f60cc7(); + 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() { + log_f60cc7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_f60cc7(); + return; +} diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.glsl new file mode 100644 index 0000000000..d29f386148 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_f60cc7() { + vec2 res = vec2(0.0f); +} + +vec4 vertex_main() { + log_f60cc7(); + 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 log_f60cc7() { + vec2 res = vec2(0.0f); +} + +void fragment_main() { + log_f60cc7(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_f60cc7() { + vec2 res = vec2(0.0f); +} + +void compute_main() { + log_f60cc7(); +} + +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/log/f60cc7.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.msl new file mode 100644 index 0000000000..831c100b9c --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_f60cc7() { + float2 res = float2(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_f60cc7(); + 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() { + log_f60cc7(); + return; +} + +kernel void compute_main() { + log_f60cc7(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.spvasm new file mode 100644 index 0000000000..f7f08c4196 --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log_f60cc7 "log_f60cc7" + 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 + %14 = OpConstantNull %v2float +%_ptr_Function_v2float = OpTypePointer Function %v2float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_f60cc7 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_f60cc7 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_f60cc7 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log_f60cc7 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.wgsl new file mode 100644 index 0000000000..071eddf9fd --- /dev/null +++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log_f60cc7() { + var res = log(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_f60cc7(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_f60cc7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_f60cc7(); +} diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl new file mode 100644 index 0000000000..4e61b7b2f9 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.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 log2(vec<3, fa>) -> vec<3, fa> +fn log2_0fbd39() { + var res = log2(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_0fbd39(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_0fbd39(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_0fbd39(); +} diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..9ddf089f75 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_0fbd39() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_0fbd39(); + 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() { + log2_0fbd39(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_0fbd39(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..9ddf089f75 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_0fbd39() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_0fbd39(); + 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() { + log2_0fbd39(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_0fbd39(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.glsl new file mode 100644 index 0000000000..97598334a5 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_0fbd39() { + vec3 res = vec3(0.0f); +} + +vec4 vertex_main() { + log2_0fbd39(); + 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 log2_0fbd39() { + vec3 res = vec3(0.0f); +} + +void fragment_main() { + log2_0fbd39(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_0fbd39() { + vec3 res = vec3(0.0f); +} + +void compute_main() { + log2_0fbd39(); +} + +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/log2/0fbd39.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.msl new file mode 100644 index 0000000000..f9e505a84f --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_0fbd39() { + float3 res = float3(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_0fbd39(); + 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() { + log2_0fbd39(); + return; +} + +kernel void compute_main() { + log2_0fbd39(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.spvasm new file mode 100644 index 0000000000..b98320103d --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log2_0fbd39 "log2_0fbd39" + 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 + %14 = OpConstantNull %v3float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_0fbd39 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_0fbd39 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_0fbd39 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log2_0fbd39 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.wgsl new file mode 100644 index 0000000000..1c8922fc58 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log2_0fbd39() { + var res = log2(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_0fbd39(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_0fbd39(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_0fbd39(); +} diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl index 487dd6f4d0..e03ccef504 100644 --- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_38b478() { - vector res = log2((float16_t(1.0h)).xxx); + vector res = (float16_t(0.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl index a48af868b8..747de5e33a 100644 --- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log2_38b478() { - f16vec3 res = log2(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log2_38b478() { - f16vec3 res = log2(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log2_38b478() { - f16vec3 res = log2(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl index 8a6fb00b02..c5df79a050 100644 --- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_38b478() { - half3 res = log2(half3(1.0h)); + half3 res = half3(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm index e150bb54a0..e8a7567f68 100644 --- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,35 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 + %15 = OpConstantNull %v3half %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log2_38b478 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Log2 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %15 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %log2_38b478 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %log2_38b478 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %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 - %31 = OpLabel - %32 = OpFunctionCall %void %log2_38b478 + %27 = OpLabel + %28 = OpFunctionCall %void %log2_38b478 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %log2_38b478 + %30 = OpLabel + %31 = OpFunctionCall %void %log2_38b478 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl index 1bea97c647..da5dd4e515 100644 --- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_4036ed() { - float res = log2(1.0f); + float res = 0.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl index 1bea97c647..da5dd4e515 100644 --- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log2_4036ed() { - float res = log2(1.0f); + float res = 0.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl index 842c021751..01c3ca01c9 100644 --- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log2_4036ed() { - float res = log2(1.0f); + float res = 0.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log2_4036ed() { - float res = log2(1.0f); + float res = 0.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log2_4036ed() { - float res = log2(1.0f); + float res = 0.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl index e88769f8e0..12a5aec9b6 100644 --- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_4036ed() { - float res = log2(1.0f); + float res = 0.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm index 197b7a23d3..0f87a46fa0 100644 --- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/4036ed.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" @@ -31,35 +30,34 @@ %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 - %18 = OpTypeFunction %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log2_4036ed = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Log2 %float_1 - OpStore %res %13 + OpStore %res %8 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %log2_4036ed +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log2_4036ed OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %log2_4036ed + %24 = OpLabel + %25 = OpFunctionCall %void %log2_4036ed OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %log2_4036ed + %27 = OpLabel + %28 = OpFunctionCall %void %log2_4036ed OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl new file mode 100644 index 0000000000..4610d9482d --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.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 log2(fa) -> fa +fn log2_5b464b() { + var res = log2(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_5b464b(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_5b464b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_5b464b(); +} diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..87f9f25bd4 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_5b464b() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_5b464b(); + 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() { + log2_5b464b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_5b464b(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..87f9f25bd4 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_5b464b() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_5b464b(); + 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() { + log2_5b464b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_5b464b(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.glsl new file mode 100644 index 0000000000..1429b322d4 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_5b464b() { + float res = 0.0f; +} + +vec4 vertex_main() { + log2_5b464b(); + 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 log2_5b464b() { + float res = 0.0f; +} + +void fragment_main() { + log2_5b464b(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_5b464b() { + float res = 0.0f; +} + +void compute_main() { + log2_5b464b(); +} + +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/log2/5b464b.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.msl new file mode 100644 index 0000000000..a7547e32d7 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_5b464b() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_5b464b(); + 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() { + log2_5b464b(); + return; +} + +kernel void compute_main() { + log2_5b464b(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.spvasm new file mode 100644 index 0000000000..d42ca7e051 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.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 %log2_5b464b "log2_5b464b" + 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 +%_ptr_Function_float = OpTypePointer Function %float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_5b464b = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %8 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log2_5b464b + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log2_5b464b + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log2_5b464b + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.wgsl new file mode 100644 index 0000000000..8439fe7f77 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log2_5b464b() { + var res = log2(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_5b464b(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_5b464b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_5b464b(); +} diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl new file mode 100644 index 0000000000..0455660d7b --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.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 log2(vec<2, fa>) -> vec<2, fa> +fn log2_6b8954() { + var res = log2(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_6b8954(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_6b8954(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_6b8954(); +} diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..1bd35a79ec --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_6b8954() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_6b8954(); + 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() { + log2_6b8954(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_6b8954(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..1bd35a79ec --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_6b8954() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_6b8954(); + 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() { + log2_6b8954(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_6b8954(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.glsl new file mode 100644 index 0000000000..b7d204cde2 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_6b8954() { + vec2 res = vec2(0.0f); +} + +vec4 vertex_main() { + log2_6b8954(); + 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 log2_6b8954() { + vec2 res = vec2(0.0f); +} + +void fragment_main() { + log2_6b8954(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_6b8954() { + vec2 res = vec2(0.0f); +} + +void compute_main() { + log2_6b8954(); +} + +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/log2/6b8954.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.msl new file mode 100644 index 0000000000..8e2cad2c12 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_6b8954() { + float2 res = float2(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_6b8954(); + 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() { + log2_6b8954(); + return; +} + +kernel void compute_main() { + log2_6b8954(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.spvasm new file mode 100644 index 0000000000..e3a10e7e40 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log2_6b8954 "log2_6b8954" + 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 + %14 = OpConstantNull %v2float +%_ptr_Function_v2float = OpTypePointer Function %v2float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_6b8954 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_6b8954 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_6b8954 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log2_6b8954 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.wgsl new file mode 100644 index 0000000000..f2cf58e2b9 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log2_6b8954() { + var res = log2(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_6b8954(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_6b8954(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_6b8954(); +} diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl index 70fb5d88a4..6eba104898 100644 --- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_776088() { - vector res = log2((float16_t(1.0h)).xxxx); + vector res = (float16_t(0.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl index 2024e28d69..75dfbd1d66 100644 --- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log2_776088() { - f16vec4 res = log2(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log2_776088() { - f16vec4 res = log2(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log2_776088() { - f16vec4 res = log2(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl index 62e73b1b4a..e88c8751d7 100644 --- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_776088() { - half4 res = log2(half4(1.0h)); + half4 res = half4(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm index aa2534c2b5..965facbb03 100644 --- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,35 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 + %15 = OpConstantNull %v4half %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log2_776088 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Log2 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %15 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %log2_776088 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %log2_776088 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %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 - %31 = OpLabel - %32 = OpFunctionCall %void %log2_776088 + %27 = OpLabel + %28 = OpFunctionCall %void %log2_776088 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %log2_776088 + %30 = OpLabel + %31 = OpFunctionCall %void %log2_776088 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl index 6049929bfd..af4452e2af 100644 --- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_8c10b3() { - float16_t res = log2(float16_t(1.0h)); + float16_t res = float16_t(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl index 92d34db0ee..34fdf3706d 100644 --- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log2_8c10b3() { - float16_t res = log2(1.0hf); + float16_t res = 0.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log2_8c10b3() { - float16_t res = log2(1.0hf); + float16_t res = 0.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log2_8c10b3() { - float16_t res = log2(1.0hf); + float16_t res = 0.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl index 55342a84ff..c1d8b32349 100644 --- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_8c10b3() { - half res = log2(1.0h); + half res = 0.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm index 121842ef80..994bb146e5 100644 --- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 31 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -36,37 +35,35 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 + %14 = OpConstantNull %half %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log2_8c10b3 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Log2 %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %14 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %log2_8c10b3 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_8c10b3 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_8c10b3 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %29 = OpLabel %30 = OpFunctionCall %void %log2_8c10b3 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %log2_8c10b3 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl index 500098ebb5..d9ea63bcec 100644 --- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_902988() { - float4 res = log2((1.0f).xxxx); + float4 res = (0.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl index 500098ebb5..d9ea63bcec 100644 --- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log2_902988() { - float4 res = log2((1.0f).xxxx); + float4 res = (0.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl index 117b10c28d..472adc5533 100644 --- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log2_902988() { - vec4 res = log2(vec4(1.0f)); + vec4 res = vec4(0.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log2_902988() { - vec4 res = log2(vec4(1.0f)); + vec4 res = vec4(0.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log2_902988() { - vec4 res = log2(vec4(1.0f)); + vec4 res = vec4(0.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl index 354f7615a7..8d88fe827c 100644 --- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_902988() { - float4 res = log2(float4(1.0f)); + float4 res = float4(0.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm index 6a493b9d81..6d40f39792 100644 --- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; 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" @@ -31,36 +30,34 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log2_902988 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Log2 %16 - OpStore %res %13 + OpStore %res %5 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %log2_902988 +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log2_902988 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log2_902988 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %27 = OpLabel %28 = OpFunctionCall %void %log2_902988 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %log2_902988 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl new file mode 100644 index 0000000000..bde0cbbc75 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.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 log2(vec<4, fa>) -> vec<4, fa> +fn log2_a52bbb() { + var res = log2(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_a52bbb(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_a52bbb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_a52bbb(); +} diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..4ea9b28c32 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_a52bbb() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_a52bbb(); + 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() { + log2_a52bbb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_a52bbb(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..4ea9b28c32 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_a52bbb() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_a52bbb(); + 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() { + log2_a52bbb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_a52bbb(); + return; +} diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.glsl new file mode 100644 index 0000000000..8b2864c7ec --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_a52bbb() { + vec4 res = vec4(0.0f); +} + +vec4 vertex_main() { + log2_a52bbb(); + 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 log2_a52bbb() { + vec4 res = vec4(0.0f); +} + +void fragment_main() { + log2_a52bbb(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_a52bbb() { + vec4 res = vec4(0.0f); +} + +void compute_main() { + log2_a52bbb(); +} + +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/log2/a52bbb.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.msl new file mode 100644 index 0000000000..b1c80054ea --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_a52bbb() { + float4 res = float4(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_a52bbb(); + 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() { + log2_a52bbb(); + return; +} + +kernel void compute_main() { + log2_a52bbb(); + return; +} + diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.spvasm new file mode 100644 index 0000000000..9920241bcf --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.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 %log2_a52bbb "log2_a52bbb" + 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 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_a52bbb = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %5 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log2_a52bbb + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log2_a52bbb + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log2_a52bbb + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.wgsl new file mode 100644 index 0000000000..5b5b3a13d2 --- /dev/null +++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn log2_a52bbb() { + var res = log2(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_a52bbb(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_a52bbb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_a52bbb(); +} diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl index 73bd8d58a4..04376aa04d 100644 --- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_adb233() { - float3 res = log2((1.0f).xxx); + float3 res = (0.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl index 73bd8d58a4..04376aa04d 100644 --- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log2_adb233() { - float3 res = log2((1.0f).xxx); + float3 res = (0.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl index 82d0d605de..35de9d3fd9 100644 --- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log2_adb233() { - vec3 res = log2(vec3(1.0f)); + vec3 res = vec3(0.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log2_adb233() { - vec3 res = log2(vec3(1.0f)); + vec3 res = vec3(0.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log2_adb233() { - vec3 res = log2(vec3(1.0f)); + vec3 res = vec3(0.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl index 6d394dce9d..8b5e766ef8 100644 --- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_adb233() { - float3 res = log2(float3(1.0f)); + float3 res = float3(0.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm index ac19e978e8..6f2635a17a 100644 --- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 31 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,35 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %14 = OpConstantNull %v3float %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log2_adb233 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Log2 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %14 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %log2_adb233 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_adb233 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_adb233 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %29 = OpLabel %30 = OpFunctionCall %void %log2_adb233 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %log2_adb233 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl index 8c58800014..e6088a342f 100644 --- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_aea659() { - float2 res = log2((1.0f).xx); + float2 res = (0.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl index 8c58800014..e6088a342f 100644 --- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void log2_aea659() { - float2 res = log2((1.0f).xx); + float2 res = (0.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl index 6b1412f393..354998dbbd 100644 --- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void log2_aea659() { - vec2 res = log2(vec2(1.0f)); + vec2 res = vec2(0.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void log2_aea659() { - vec2 res = log2(vec2(1.0f)); + vec2 res = vec2(0.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void log2_aea659() { - vec2 res = log2(vec2(1.0f)); + vec2 res = vec2(0.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl index 83e3e7d1d7..ecd1f50df7 100644 --- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_aea659() { - float2 res = log2(float2(1.0f)); + float2 res = float2(0.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm index 9f381bc419..3c63c4aa2a 100644 --- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 31 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,35 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 + %14 = OpConstantNull %v2float %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %log2_aea659 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Log2 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %14 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %log2_aea659 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_aea659 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_aea659 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %29 = OpLabel %30 = OpFunctionCall %void %log2_aea659 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %log2_aea659 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl index 86a9e683b4..b09eff56f5 100644 --- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void log2_fb9f0b() { - vector res = log2((float16_t(1.0h)).xx); + vector res = (float16_t(0.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl index b768f1bb73..75a43698af 100644 --- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void log2_fb9f0b() { - f16vec2 res = log2(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void log2_fb9f0b() { - f16vec2 res = log2(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void log2_fb9f0b() { - f16vec2 res = log2(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl index bd5984ffe7..0e844fd8a0 100644 --- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void log2_fb9f0b() { - half2 res = log2(half2(1.0h)); + half2 res = half2(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm index f68a857202..8c6b96eeb8 100644 --- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,35 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 + %15 = OpConstantNull %v2half %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %log2_fb9f0b = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Log2 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %15 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %log2_fb9f0b +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %log2_fb9f0b OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %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 - %31 = OpLabel - %32 = OpFunctionCall %void %log2_fb9f0b + %27 = OpLabel + %28 = OpFunctionCall %void %log2_fb9f0b OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %log2_fb9f0b + %30 = OpLabel + %31 = OpFunctionCall %void %log2_fb9f0b OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log/655989.wgsl b/test/tint/builtins/gen/var/log/655989.wgsl new file mode 100644 index 0000000000..062a3e9a2d --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.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 log(fa) -> fa +fn log_655989() { + const arg_0 = 1.; + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_655989(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_655989(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_655989(); +} diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a8475f8637 --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_655989() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_655989(); + 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() { + log_655989(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_655989(); + return; +} diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a8475f8637 --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_655989() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_655989(); + 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() { + log_655989(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_655989(); + return; +} diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.glsl new file mode 100644 index 0000000000..e6a0182ca7 --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_655989() { + float res = 0.0f; +} + +vec4 vertex_main() { + log_655989(); + 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 log_655989() { + float res = 0.0f; +} + +void fragment_main() { + log_655989(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_655989() { + float res = 0.0f; +} + +void compute_main() { + log_655989(); +} + +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/log/655989.wgsl.expected.msl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.msl new file mode 100644 index 0000000000..0b174b7d37 --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_655989() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_655989(); + 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() { + log_655989(); + return; +} + +kernel void compute_main() { + log_655989(); + return; +} + diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/655989.wgsl.expected.spvasm new file mode 100644 index 0000000000..6d7f01bb20 --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.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 %log_655989 "log_655989" + 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 +%_ptr_Function_float = OpTypePointer Function %float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_655989 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %8 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log_655989 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log_655989 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log_655989 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.wgsl new file mode 100644 index 0000000000..64ad88d536 --- /dev/null +++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log_655989() { + const arg_0 = 1.0; + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_655989(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_655989(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_655989(); +} diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl b/test/tint/builtins/gen/var/log/697e1d.wgsl new file mode 100644 index 0000000000..7f7822f92b --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.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 log(vec<4, fa>) -> vec<4, fa> +fn log_697e1d() { + const arg_0 = vec4(1.); + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_697e1d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_697e1d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_697e1d(); +} diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..56bdd4cf08 --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_697e1d() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_697e1d(); + 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() { + log_697e1d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_697e1d(); + return; +} diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..56bdd4cf08 --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_697e1d() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_697e1d(); + 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() { + log_697e1d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_697e1d(); + return; +} diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.glsl new file mode 100644 index 0000000000..06b9a1b219 --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_697e1d() { + vec4 res = vec4(0.0f); +} + +vec4 vertex_main() { + log_697e1d(); + 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 log_697e1d() { + vec4 res = vec4(0.0f); +} + +void fragment_main() { + log_697e1d(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_697e1d() { + vec4 res = vec4(0.0f); +} + +void compute_main() { + log_697e1d(); +} + +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/log/697e1d.wgsl.expected.msl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.msl new file mode 100644 index 0000000000..c3311d430e --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_697e1d() { + float4 res = float4(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_697e1d(); + 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() { + log_697e1d(); + return; +} + +kernel void compute_main() { + log_697e1d(); + return; +} + diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.spvasm new file mode 100644 index 0000000000..743229611a --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.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 %log_697e1d "log_697e1d" + 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 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_697e1d = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %5 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log_697e1d + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log_697e1d + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log_697e1d + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.wgsl new file mode 100644 index 0000000000..e0a026c0d8 --- /dev/null +++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log_697e1d() { + const arg_0 = vec4(1.0); + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_697e1d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_697e1d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_697e1d(); +} diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl b/test/tint/builtins/gen/var/log/b8088d.wgsl new file mode 100644 index 0000000000..2bcdc0fabf --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.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 log(vec<3, fa>) -> vec<3, fa> +fn log_b8088d() { + const arg_0 = vec3(1.); + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_b8088d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_b8088d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_b8088d(); +} diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0234c1d83c --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_b8088d() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_b8088d(); + 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() { + log_b8088d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_b8088d(); + return; +} diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0234c1d83c --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_b8088d() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_b8088d(); + 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() { + log_b8088d(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_b8088d(); + return; +} diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.glsl new file mode 100644 index 0000000000..5dc623a06b --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_b8088d() { + vec3 res = vec3(0.0f); +} + +vec4 vertex_main() { + log_b8088d(); + 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 log_b8088d() { + vec3 res = vec3(0.0f); +} + +void fragment_main() { + log_b8088d(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_b8088d() { + vec3 res = vec3(0.0f); +} + +void compute_main() { + log_b8088d(); +} + +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/log/b8088d.wgsl.expected.msl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.msl new file mode 100644 index 0000000000..92066b0a75 --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_b8088d() { + float3 res = float3(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_b8088d(); + 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() { + log_b8088d(); + return; +} + +kernel void compute_main() { + log_b8088d(); + return; +} + diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.spvasm new file mode 100644 index 0000000000..ed2010a743 --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log_b8088d "log_b8088d" + 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 + %14 = OpConstantNull %v3float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_b8088d = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_b8088d + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_b8088d + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log_b8088d + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.wgsl new file mode 100644 index 0000000000..75039e7ea2 --- /dev/null +++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log_b8088d() { + const arg_0 = vec3(1.0); + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_b8088d(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_b8088d(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_b8088d(); +} diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl new file mode 100644 index 0000000000..ea4f452bb0 --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.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 log(vec<2, fa>) -> vec<2, fa> +fn log_f60cc7() { + const arg_0 = vec2(1.); + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_f60cc7(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_f60cc7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_f60cc7(); +} diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..41dbc64b8e --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log_f60cc7() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_f60cc7(); + 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() { + log_f60cc7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_f60cc7(); + return; +} diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..41dbc64b8e --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log_f60cc7() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log_f60cc7(); + 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() { + log_f60cc7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log_f60cc7(); + return; +} diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.glsl new file mode 100644 index 0000000000..d29f386148 --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log_f60cc7() { + vec2 res = vec2(0.0f); +} + +vec4 vertex_main() { + log_f60cc7(); + 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 log_f60cc7() { + vec2 res = vec2(0.0f); +} + +void fragment_main() { + log_f60cc7(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log_f60cc7() { + vec2 res = vec2(0.0f); +} + +void compute_main() { + log_f60cc7(); +} + +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/log/f60cc7.wgsl.expected.msl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.msl new file mode 100644 index 0000000000..831c100b9c --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log_f60cc7() { + float2 res = float2(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log_f60cc7(); + 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() { + log_f60cc7(); + return; +} + +kernel void compute_main() { + log_f60cc7(); + return; +} + diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.spvasm new file mode 100644 index 0000000000..f7f08c4196 --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log_f60cc7 "log_f60cc7" + 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 + %14 = OpConstantNull %v2float +%_ptr_Function_v2float = OpTypePointer Function %v2float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %log_f60cc7 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log_f60cc7 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log_f60cc7 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log_f60cc7 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.wgsl new file mode 100644 index 0000000000..7f736abc56 --- /dev/null +++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log_f60cc7() { + const arg_0 = vec2(1.0); + var res = log(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log_f60cc7(); + return vec4(); +} + +@fragment +fn fragment_main() { + log_f60cc7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log_f60cc7(); +} diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl new file mode 100644 index 0000000000..c61df79160 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.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 log2(vec<3, fa>) -> vec<3, fa> +fn log2_0fbd39() { + const arg_0 = vec3(1.); + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_0fbd39(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_0fbd39(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_0fbd39(); +} diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..9ddf089f75 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_0fbd39() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_0fbd39(); + 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() { + log2_0fbd39(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_0fbd39(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..9ddf089f75 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_0fbd39() { + float3 res = (0.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_0fbd39(); + 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() { + log2_0fbd39(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_0fbd39(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.glsl new file mode 100644 index 0000000000..97598334a5 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_0fbd39() { + vec3 res = vec3(0.0f); +} + +vec4 vertex_main() { + log2_0fbd39(); + 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 log2_0fbd39() { + vec3 res = vec3(0.0f); +} + +void fragment_main() { + log2_0fbd39(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_0fbd39() { + vec3 res = vec3(0.0f); +} + +void compute_main() { + log2_0fbd39(); +} + +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/log2/0fbd39.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.msl new file mode 100644 index 0000000000..f9e505a84f --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_0fbd39() { + float3 res = float3(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_0fbd39(); + 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() { + log2_0fbd39(); + return; +} + +kernel void compute_main() { + log2_0fbd39(); + return; +} + diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.spvasm new file mode 100644 index 0000000000..b98320103d --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log2_0fbd39 "log2_0fbd39" + 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 + %14 = OpConstantNull %v3float +%_ptr_Function_v3float = OpTypePointer Function %v3float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_0fbd39 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_0fbd39 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_0fbd39 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log2_0fbd39 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.wgsl new file mode 100644 index 0000000000..d92b5ad73a --- /dev/null +++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log2_0fbd39() { + const arg_0 = vec3(1.0); + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_0fbd39(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_0fbd39(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_0fbd39(); +} diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl new file mode 100644 index 0000000000..ec035202d1 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.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 log2(fa) -> fa +fn log2_5b464b() { + const arg_0 = 1.; + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_5b464b(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_5b464b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_5b464b(); +} diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..87f9f25bd4 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_5b464b() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_5b464b(); + 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() { + log2_5b464b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_5b464b(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..87f9f25bd4 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_5b464b() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_5b464b(); + 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() { + log2_5b464b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_5b464b(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.glsl new file mode 100644 index 0000000000..1429b322d4 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_5b464b() { + float res = 0.0f; +} + +vec4 vertex_main() { + log2_5b464b(); + 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 log2_5b464b() { + float res = 0.0f; +} + +void fragment_main() { + log2_5b464b(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_5b464b() { + float res = 0.0f; +} + +void compute_main() { + log2_5b464b(); +} + +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/log2/5b464b.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.msl new file mode 100644 index 0000000000..a7547e32d7 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_5b464b() { + float res = 0.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_5b464b(); + 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() { + log2_5b464b(); + return; +} + +kernel void compute_main() { + log2_5b464b(); + return; +} + diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.spvasm new file mode 100644 index 0000000000..d42ca7e051 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.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 %log2_5b464b "log2_5b464b" + 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 +%_ptr_Function_float = OpTypePointer Function %float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_5b464b = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %8 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log2_5b464b + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log2_5b464b + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log2_5b464b + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.wgsl new file mode 100644 index 0000000000..b824c8e028 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log2_5b464b() { + const arg_0 = 1.0; + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_5b464b(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_5b464b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_5b464b(); +} diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl new file mode 100644 index 0000000000..adc94008ab --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.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 log2(vec<2, fa>) -> vec<2, fa> +fn log2_6b8954() { + const arg_0 = vec2(1.); + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_6b8954(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_6b8954(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_6b8954(); +} diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..1bd35a79ec --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_6b8954() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_6b8954(); + 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() { + log2_6b8954(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_6b8954(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..1bd35a79ec --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_6b8954() { + float2 res = (0.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_6b8954(); + 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() { + log2_6b8954(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_6b8954(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.glsl new file mode 100644 index 0000000000..b7d204cde2 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_6b8954() { + vec2 res = vec2(0.0f); +} + +vec4 vertex_main() { + log2_6b8954(); + 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 log2_6b8954() { + vec2 res = vec2(0.0f); +} + +void fragment_main() { + log2_6b8954(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_6b8954() { + vec2 res = vec2(0.0f); +} + +void compute_main() { + log2_6b8954(); +} + +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/log2/6b8954.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.msl new file mode 100644 index 0000000000..8e2cad2c12 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_6b8954() { + float2 res = float2(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_6b8954(); + 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() { + log2_6b8954(); + return; +} + +kernel void compute_main() { + log2_6b8954(); + return; +} + diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.spvasm new file mode 100644 index 0000000000..e3a10e7e40 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %log2_6b8954 "log2_6b8954" + 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 + %14 = OpConstantNull %v2float +%_ptr_Function_v2float = OpTypePointer Function %v2float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_6b8954 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %14 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %log2_6b8954 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %log2_6b8954 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %log2_6b8954 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.wgsl new file mode 100644 index 0000000000..52e460430c --- /dev/null +++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log2_6b8954() { + const arg_0 = vec2(1.0); + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_6b8954(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_6b8954(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_6b8954(); +} diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl new file mode 100644 index 0000000000..4d4cf717c8 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.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 log2(vec<4, fa>) -> vec<4, fa> +fn log2_a52bbb() { + const arg_0 = vec4(1.); + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_a52bbb(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_a52bbb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_a52bbb(); +} diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..4ea9b28c32 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void log2_a52bbb() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_a52bbb(); + 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() { + log2_a52bbb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_a52bbb(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..4ea9b28c32 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void log2_a52bbb() { + float4 res = (0.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + log2_a52bbb(); + 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() { + log2_a52bbb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + log2_a52bbb(); + return; +} diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.glsl new file mode 100644 index 0000000000..8b2864c7ec --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void log2_a52bbb() { + vec4 res = vec4(0.0f); +} + +vec4 vertex_main() { + log2_a52bbb(); + 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 log2_a52bbb() { + vec4 res = vec4(0.0f); +} + +void fragment_main() { + log2_a52bbb(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void log2_a52bbb() { + vec4 res = vec4(0.0f); +} + +void compute_main() { + log2_a52bbb(); +} + +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/log2/a52bbb.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.msl new file mode 100644 index 0000000000..b1c80054ea --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void log2_a52bbb() { + float4 res = float4(0.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + log2_a52bbb(); + 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() { + log2_a52bbb(); + return; +} + +kernel void compute_main() { + log2_a52bbb(); + return; +} + diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.spvasm new file mode 100644 index 0000000000..9920241bcf --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.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 %log2_a52bbb "log2_a52bbb" + 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 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %15 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%log2_a52bbb = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %5 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %15 + %17 = OpLabel + %18 = OpFunctionCall %void %log2_a52bbb + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %20 = OpLabel + %21 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %21 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %log2_a52bbb + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %log2_a52bbb + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.wgsl new file mode 100644 index 0000000000..506d5f0196 --- /dev/null +++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn log2_a52bbb() { + const arg_0 = vec4(1.0); + var res = log2(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + log2_a52bbb(); + return vec4(); +} + +@fragment +fn fragment_main() { + log2_a52bbb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + log2_a52bbb(); +}