diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 7e367505ff..3a2219a541 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -531,8 +531,8 @@ fn ldexp(vec, vec) -> vec @const fn pack2x16unorm(vec2) -> u32 @const fn pack4x8snorm(vec4) -> u32 @const fn pack4x8unorm(vec4) -> u32 -fn pow(T, T) -> T -fn pow(vec, vec) -> vec +@const fn pow(T, T) -> T +@const fn pow(vec, vec) -> vec @const fn quantizeToF16(f32) -> f32 @const fn quantizeToF16(vec) -> vec @const fn radians(T) -> T diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 1587ee147b..97f8cc403b 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -204,10 +204,10 @@ std::string OverflowErrorMessage(VALUE_TY value, std::string_view target_ty) { } template -std::string OverflowExpErrorMessage(std::string_view base, NumberT value) { +std::string OverflowExpErrorMessage(std::string_view base, NumberT exp) { std::stringstream ss; ss << std::setprecision(20); - ss << base << "^" << value << " cannot be represented as " + ss << base << "^" << exp << " cannot be represented as " << "'" << FriendlyName() << "'"; return ss.str(); } @@ -463,6 +463,7 @@ struct Composite : ImplConstant { /// CreateElement constructs and returns an Element. template ImplResult CreateElement(ProgramBuilder& builder, const Source& source, const type::Type* t, T v) { + static_assert(IsNumber || std::is_same_v, "T must be a Number or bool"); TINT_ASSERT(Resolver, t->is_scalar()); if constexpr (IsFloatingPoint) { @@ -3075,6 +3076,23 @@ ConstEval::Result ConstEval::pack4x8unorm(const type::Type* ty, return CreateElement(builder, source, ty, ret); } +ConstEval::Result ConstEval::pow(const type::Type* ty, + utils::VectorRef args, + const Source& source) { + auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { + auto create = [&](auto e1, auto e2) -> ImplResult { + auto r = CheckedPow(e1, e2); + if (!r) { + AddError(OverflowErrorMessage(e1, "^", e2), source); + return utils::Failure; + } + return CreateElement(builder, source, c0->Type(), *r); + }; + return Dispatch_fa_f32_f16(create, c0, c1); + }; + return TransformElements(builder, ty, transform, args[0], args[1]); +} + ConstEval::Result ConstEval::radians(const type::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 742089d6d8..4a99bc0f2d 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -833,6 +833,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// pow 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 pow(const type::Type* ty, + utils::VectorRef args, + const Source& source); + /// radians 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 40c65003d8..82c6d38e8f 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1971,6 +1971,54 @@ INSTANTIATE_TEST_SUITE_P( // testing::Combine(testing::Values(sem::BuiltinType::kPack2X16Unorm), testing::ValuesIn(Pack2x16unormCases()))); +template +std::vector PowCases() { + auto error_msg = [](auto base, auto exp) { + return "12:34 error: " + OverflowErrorMessage(base, "^", exp); + }; + return { + C({T(0), T(1)}, T(0)), // + C({T(0), T::Highest()}, T(0)), // + C({T(1), T(1)}, T(1)), // + C({T(1), T::Lowest()}, T(1)), // + C({T(2), T(2)}, T(4)), // + C({T(2), T(3)}, T(8)), // + // Positive base, negative exponent + C({T(1), T::Highest()}, T(1)), // + C({T(1), -T(1)}, T(1)), // + C({T(2), -T(2)}, T(0.25)), // + C({T(2), -T(3)}, T(0.125)), // + // Decimal values + C({T(2.5), T(3)}, T(15.625)), // + C({T(2), T(3.5)}, T(11.313708498)).FloatComp(), // + C({T(2.5), T(3.5)}, T(24.705294220)).FloatComp(), // + C({T(2), -T(3.5)}, T(0.0883883476)).FloatComp(), // + + // Vector tests + C({Vec(T(0), T(1), T(2)), Vec(T(2), T(2), T(2))}, Vec(T(0), T(1), T(4))), + C({Vec(T(2), T(2), T(2)), Vec(T(2), T(3), T(4))}, Vec(T(4), T(8), T(16))), + + // Error if base < 0 + E({-T(1), T(1)}, error_msg(-T(1), T(1))), + E({-T(1), T::Highest()}, error_msg(-T(1), T::Highest())), + E({T::Lowest(), T(1)}, error_msg(T::Lowest(), T(1))), + E({T::Lowest(), T::Highest()}, error_msg(T::Lowest(), T::Highest())), + E({T::Lowest(), T::Lowest()}, error_msg(T::Lowest(), T::Lowest())), + + // Error if base == 0 and exp <= 0 + E({T(0), T(0)}, error_msg(T(0), T(0))), + E({T(0), -T(1)}, error_msg(T(0), -T(1))), + E({T(0), T::Lowest()}, error_msg(T(0), T::Lowest())), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Pow, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kPow), + testing::ValuesIn(Concat(PowCases(), // + PowCases(), // + PowCases())))); + template std::vector ReverseBitsCases() { using B = BitValues; diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h index fd39286b06..0429e8f8d3 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -238,10 +238,10 @@ std::string OverflowErrorMessage(VALUE_TY value, std::string_view target_ty) { /// Returns the overflow error message for exponentiation template -std::string OverflowExpErrorMessage(std::string_view base, NumberT value) { +std::string OverflowExpErrorMessage(std::string_view base, NumberT exp) { std::stringstream ss; ss << std::setprecision(20); - ss << base << "^" << value << " cannot be represented as " + ss << base << "^" << exp << " cannot be represented as " << "'" << FriendlyName() << "'"; return ss.str(); } diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index bda62382dc..fd2822b819 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12797,24 +12797,24 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[622], /* return matcher indices */ &kMatcherIndices[3], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::pow, }, { /* [376] */ /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[624], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::pow, }, { /* [377] */ @@ -14345,8 +14345,8 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [60] */ - /* fn pow(T, T) -> T */ - /* fn pow(vec, vec) -> vec */ + /* fn pow(T, T) -> T */ + /* fn pow(vec, vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[375], }, diff --git a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.dxc.hlsl index 7006eef600..1ae010530c 100644 --- a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_04a908() { - float4 res = pow((1.0f).xxxx, (1.0f).xxxx); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.fxc.hlsl index 7006eef600..1ae010530c 100644 --- a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void pow_04a908() { - float4 res = pow((1.0f).xxxx, (1.0f).xxxx); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.glsl index dc7e2f6e84..139e5c2413 100644 --- a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void pow_04a908() { - vec4 res = pow(vec4(1.0f), vec4(1.0f)); + vec4 res = vec4(1.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void pow_04a908() { - vec4 res = pow(vec4(1.0f), vec4(1.0f)); + vec4 res = vec4(1.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void pow_04a908() { - vec4 res = pow(vec4(1.0f), vec4(1.0f)); + vec4 res = vec4(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.msl index 647e665fca..47d2531530 100644 --- a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_04a908() { - float4 res = pow(float4(1.0f), float4(1.0f)); + float4 res = float4(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.spvasm index 614ed9b1c8..fdf4f0a66d 100644 --- a/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/04a908.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,35 +31,34 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float %pow_04a908 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Pow %16 %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %pow_04a908 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %pow_04a908 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %pow_04a908 + %25 = OpLabel + %26 = OpFunctionCall %void %pow_04a908 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %pow_04a908 + %28 = OpLabel + %29 = OpFunctionCall %void %pow_04a908 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.dxc.hlsl index e7864f33c3..5d97ebd6ed 100644 --- a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_46e029() { - float res = pow(1.0f, 1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.fxc.hlsl index e7864f33c3..5d97ebd6ed 100644 --- a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void pow_46e029() { - float res = pow(1.0f, 1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.glsl index 4e3a1e9f82..570c2912d6 100644 --- a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void pow_46e029() { - float res = pow(1.0f, 1.0f); + float res = 1.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void pow_46e029() { - float res = pow(1.0f, 1.0f); + float res = 1.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void pow_46e029() { - float res = pow(1.0f, 1.0f); + float res = 1.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.msl index bd126032d2..f6b1cd99fc 100644 --- a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_46e029() { - float res = pow(1.0f, 1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.spvasm index 9fb544623d..dba627f244 100644 --- a/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/46e029.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 29 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -33,33 +32,32 @@ %9 = OpTypeFunction %void %float_1 = OpConstant %float 1 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float %pow_46e029 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Pow %float_1 %float_1 - OpStore %res %13 + OpStore %res %float_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %pow_46e029 +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %pow_46e029 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %pow_46e029 + %24 = OpLabel + %25 = OpFunctionCall %void %pow_46e029 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %pow_46e029 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_46e029 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.dxc.hlsl index 282199079e..56a6bf719d 100644 --- a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_4a46c9() { - float3 res = pow((1.0f).xxx, (1.0f).xxx); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.fxc.hlsl index 282199079e..56a6bf719d 100644 --- a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void pow_4a46c9() { - float3 res = pow((1.0f).xxx, (1.0f).xxx); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.glsl index 36ad96855b..11cb9b9f76 100644 --- a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void pow_4a46c9() { - vec3 res = pow(vec3(1.0f), vec3(1.0f)); + vec3 res = vec3(1.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void pow_4a46c9() { - vec3 res = pow(vec3(1.0f), vec3(1.0f)); + vec3 res = vec3(1.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void pow_4a46c9() { - vec3 res = pow(vec3(1.0f), vec3(1.0f)); + vec3 res = vec3(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.msl index e0fa00c674..2c06a34ea6 100644 --- a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_4a46c9() { - float3 res = pow(float3(1.0f), float3(1.0f)); + float3 res = float3(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.spvasm index 01a3076e98..dd4ce2622e 100644 --- a/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/4a46c9.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -33,36 +32,35 @@ %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float %pow_4a46c9 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Pow %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %pow_4a46c9 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %pow_4a46c9 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %pow_4a46c9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_4a46c9 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %pow_4a46c9 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_4a46c9 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.dxc.hlsl index 279bbacf6e..b265ae4aaf 100644 --- a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_4f33b2() { - vector res = pow((float16_t(1.0h)).xxxx, (float16_t(1.0h)).xxxx); + vector res = (float16_t(1.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.glsl index 2a31c9138c..685d96952d 100644 --- a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void pow_4f33b2() { - f16vec4 res = pow(f16vec4(1.0hf), f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void pow_4f33b2() { - f16vec4 res = pow(f16vec4(1.0hf), f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void pow_4f33b2() { - f16vec4 res = pow(f16vec4(1.0hf), f16vec4(1.0hf)); + f16vec4 res = f16vec4(1.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.msl index 8f249be15b..652fe80c70 100644 --- a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_4f33b2() { - half4 res = pow(half4(1.0h), half4(1.0h)); + half4 res = half4(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.spvasm index be0a42abd5..475e4b4f86 100644 --- a/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/4f33b2.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -38,37 +37,36 @@ %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 %half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 + %16 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %pow_4f33b2 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Pow %18 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %pow_4f33b2 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %pow_4f33b2 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %pow_4f33b2 + %29 = OpLabel + %30 = OpFunctionCall %void %pow_4f33b2 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %pow_4f33b2 + %32 = OpLabel + %33 = OpFunctionCall %void %pow_4f33b2 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/749c42.wgsl b/test/tint/builtins/gen/literal/pow/749c42.wgsl new file mode 100644 index 0000000000..e1c6acc592 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.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 pow(fa, fa) -> fa +fn pow_749c42() { + var res = pow(1., 1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_749c42(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_749c42(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_749c42(); +} diff --git a/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..ecbf0c07b4 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_749c42() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_749c42(); + 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() { + pow_749c42(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_749c42(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..ecbf0c07b4 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_749c42() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_749c42(); + 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() { + pow_749c42(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_749c42(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.glsl new file mode 100644 index 0000000000..d61fbdb455 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_749c42() { + float res = 1.0f; +} + +vec4 vertex_main() { + pow_749c42(); + 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 pow_749c42() { + float res = 1.0f; +} + +void fragment_main() { + pow_749c42(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_749c42() { + float res = 1.0f; +} + +void compute_main() { + pow_749c42(); +} + +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/pow/749c42.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.msl new file mode 100644 index 0000000000..5aa140a06f --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_749c42() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_749c42(); + 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() { + pow_749c42(); + return; +} + +kernel void compute_main() { + pow_749c42(); + return; +} + diff --git a/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.spvasm new file mode 100644 index 0000000000..52a393b96c --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.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 %pow_749c42 "pow_749c42" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %pow_749c42 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %pow_749c42 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %pow_749c42 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_749c42 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.wgsl new file mode 100644 index 0000000000..cadc514198 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/749c42.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn pow_749c42() { + var res = pow(1.0, 1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_749c42(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_749c42(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_749c42(); +} diff --git a/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl new file mode 100644 index 0000000000..83e8d64c84 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.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 pow(vec<4, fa>, vec<4, fa>) -> vec<4, fa> +fn pow_a8f6b2() { + var res = pow(vec4(1.), vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_a8f6b2(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_a8f6b2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_a8f6b2(); +} diff --git a/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a36a572fc0 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_a8f6b2() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_a8f6b2(); + 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() { + pow_a8f6b2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_a8f6b2(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a36a572fc0 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_a8f6b2() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_a8f6b2(); + 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() { + pow_a8f6b2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_a8f6b2(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.glsl new file mode 100644 index 0000000000..d5d0cf0c79 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_a8f6b2() { + vec4 res = vec4(1.0f); +} + +vec4 vertex_main() { + pow_a8f6b2(); + 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 pow_a8f6b2() { + vec4 res = vec4(1.0f); +} + +void fragment_main() { + pow_a8f6b2(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_a8f6b2() { + vec4 res = vec4(1.0f); +} + +void compute_main() { + pow_a8f6b2(); +} + +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/pow/a8f6b2.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.msl new file mode 100644 index 0000000000..36e1b89214 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_a8f6b2() { + float4 res = float4(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_a8f6b2(); + 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() { + pow_a8f6b2(); + return; +} + +kernel void compute_main() { + pow_a8f6b2(); + return; +} + diff --git a/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.spvasm new file mode 100644 index 0000000000..32d0af3c2b --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %pow_a8f6b2 "pow_a8f6b2" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %pow_a8f6b2 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %pow_a8f6b2 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %pow_a8f6b2 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %pow_a8f6b2 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.wgsl new file mode 100644 index 0000000000..c5553fba10 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/a8f6b2.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn pow_a8f6b2() { + var res = pow(vec4(1.0), vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_a8f6b2(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_a8f6b2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_a8f6b2(); +} diff --git a/test/tint/builtins/gen/literal/pow/bc91ed.wgsl b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl new file mode 100644 index 0000000000..3885637513 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.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 pow(vec<2, fa>, vec<2, fa>) -> vec<2, fa> +fn pow_bc91ed() { + var res = pow(vec2(1.), vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_bc91ed(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_bc91ed(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_bc91ed(); +} diff --git a/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..2b5dc1c210 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_bc91ed() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_bc91ed(); + 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() { + pow_bc91ed(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_bc91ed(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..2b5dc1c210 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_bc91ed() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_bc91ed(); + 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() { + pow_bc91ed(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_bc91ed(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.glsl new file mode 100644 index 0000000000..892ea2e097 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_bc91ed() { + vec2 res = vec2(1.0f); +} + +vec4 vertex_main() { + pow_bc91ed(); + 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 pow_bc91ed() { + vec2 res = vec2(1.0f); +} + +void fragment_main() { + pow_bc91ed(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_bc91ed() { + vec2 res = vec2(1.0f); +} + +void compute_main() { + pow_bc91ed(); +} + +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/pow/bc91ed.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.msl new file mode 100644 index 0000000000..47cfcb236b --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_bc91ed() { + float2 res = float2(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_bc91ed(); + 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() { + pow_bc91ed(); + return; +} + +kernel void compute_main() { + pow_bc91ed(); + return; +} + diff --git a/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.spvasm new file mode 100644 index 0000000000..543384177b --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %pow_bc91ed "pow_bc91ed" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v2float %float_1 %float_1 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %pow_bc91ed = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %pow_bc91ed + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_bc91ed + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_bc91ed + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.wgsl new file mode 100644 index 0000000000..e9336ab8ff --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/bc91ed.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn pow_bc91ed() { + var res = pow(vec2(1.0), vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_bc91ed(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_bc91ed(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_bc91ed(); +} diff --git a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.dxc.hlsl index b2a002c2cf..dc03903c96 100644 --- a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_ce9ef5() { - float16_t res = pow(float16_t(1.0h), float16_t(1.0h)); + float16_t res = float16_t(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.glsl index 3363c82110..a3e589a526 100644 --- a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void pow_ce9ef5() { - float16_t res = pow(1.0hf, 1.0hf); + float16_t res = 1.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void pow_ce9ef5() { - float16_t res = pow(1.0hf, 1.0hf); + float16_t res = 1.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void pow_ce9ef5() { - float16_t res = pow(1.0hf, 1.0hf); + float16_t res = 1.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.msl index 45bbe91a31..46b6ca6083 100644 --- a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_ce9ef5() { - half res = pow(1.0h, 1.0h); + half res = 1.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.spvasm index 67c724021a..6d2f5a74c7 100644 --- a/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/ce9ef5.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -38,35 +37,34 @@ %half = OpTypeFloat 16 %half_0x1p_0 = OpConstant %half 0x1p+0 %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %pow_ce9ef5 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Pow %half_0x1p_0 %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1p_0 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %pow_ce9ef5 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %pow_ce9ef5 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %pow_ce9ef5 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_ce9ef5 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %pow_ce9ef5 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_ce9ef5 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/e42f20.wgsl b/test/tint/builtins/gen/literal/pow/e42f20.wgsl new file mode 100644 index 0000000000..066b74a729 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.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 pow(vec<3, fa>, vec<3, fa>) -> vec<3, fa> +fn pow_e42f20() { + var res = pow(vec3(1.), vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_e42f20(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_e42f20(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_e42f20(); +} diff --git a/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a46c9fa0b9 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_e42f20() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_e42f20(); + 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() { + pow_e42f20(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_e42f20(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a46c9fa0b9 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_e42f20() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_e42f20(); + 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() { + pow_e42f20(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_e42f20(); + return; +} diff --git a/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.glsl new file mode 100644 index 0000000000..576ef1f5e9 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_e42f20() { + vec3 res = vec3(1.0f); +} + +vec4 vertex_main() { + pow_e42f20(); + 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 pow_e42f20() { + vec3 res = vec3(1.0f); +} + +void fragment_main() { + pow_e42f20(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_e42f20() { + vec3 res = vec3(1.0f); +} + +void compute_main() { + pow_e42f20(); +} + +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/pow/e42f20.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.msl new file mode 100644 index 0000000000..c5703d09f9 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_e42f20() { + float3 res = float3(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_e42f20(); + 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() { + pow_e42f20(); + return; +} + +kernel void compute_main() { + pow_e42f20(); + return; +} + diff --git a/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.spvasm new file mode 100644 index 0000000000..6386fcf687 --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %pow_e42f20 "pow_e42f20" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %pow_e42f20 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %pow_e42f20 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_e42f20 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_e42f20 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.wgsl new file mode 100644 index 0000000000..23af6f134e --- /dev/null +++ b/test/tint/builtins/gen/literal/pow/e42f20.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn pow_e42f20() { + var res = pow(vec3(1.0), vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_e42f20(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_e42f20(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_e42f20(); +} diff --git a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.dxc.hlsl index 1a7b88c2cd..972f4c3b7c 100644 --- a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_e60ea5() { - float2 res = pow((1.0f).xx, (1.0f).xx); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.fxc.hlsl index 1a7b88c2cd..972f4c3b7c 100644 --- a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void pow_e60ea5() { - float2 res = pow((1.0f).xx, (1.0f).xx); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.glsl index ede9a15093..09a81b2164 100644 --- a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void pow_e60ea5() { - vec2 res = pow(vec2(1.0f), vec2(1.0f)); + vec2 res = vec2(1.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void pow_e60ea5() { - vec2 res = pow(vec2(1.0f), vec2(1.0f)); + vec2 res = vec2(1.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void pow_e60ea5() { - vec2 res = pow(vec2(1.0f), vec2(1.0f)); + vec2 res = vec2(1.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.msl index 5a964bad28..f416b4c796 100644 --- a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_e60ea5() { - float2 res = pow(float2(1.0f), float2(1.0f)); + float2 res = float2(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.spvasm index 17d1989a1e..79fe8c3fe8 100644 --- a/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/e60ea5.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -33,36 +32,35 @@ %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 + %15 = OpConstantComposite %v2float %float_1 %float_1 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float %pow_e60ea5 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Pow %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %pow_e60ea5 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %pow_e60ea5 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %pow_e60ea5 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_e60ea5 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %pow_e60ea5 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_e60ea5 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.dxc.hlsl index 6a13f47ebe..e2d71b3994 100644 --- a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_f37b25() { - vector res = pow((float16_t(1.0h)).xx, (float16_t(1.0h)).xx); + vector res = (float16_t(1.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.glsl index c49c6cc944..bc15e2a901 100644 --- a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void pow_f37b25() { - f16vec2 res = pow(f16vec2(1.0hf), f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void pow_f37b25() { - f16vec2 res = pow(f16vec2(1.0hf), f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void pow_f37b25() { - f16vec2 res = pow(f16vec2(1.0hf), f16vec2(1.0hf)); + f16vec2 res = f16vec2(1.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.msl index f2862ed49a..9510344664 100644 --- a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_f37b25() { - half2 res = pow(half2(1.0h), half2(1.0h)); + half2 res = half2(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.spvasm index 88e21b6b1f..2ab5bca689 100644 --- a/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/f37b25.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -38,37 +37,36 @@ %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 %half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 + %16 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %pow_f37b25 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Pow %18 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %pow_f37b25 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %pow_f37b25 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %pow_f37b25 + %29 = OpLabel + %30 = OpFunctionCall %void %pow_f37b25 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %pow_f37b25 + %32 = OpLabel + %33 = OpFunctionCall %void %pow_f37b25 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.dxc.hlsl index a7106e4b23..dae5676138 100644 --- a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void pow_fa5429() { - vector res = pow((float16_t(1.0h)).xxx, (float16_t(1.0h)).xxx); + vector res = (float16_t(1.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.glsl b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.glsl index 289c6e67e5..be0b8fdf6c 100644 --- a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void pow_fa5429() { - f16vec3 res = pow(f16vec3(1.0hf), f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void pow_fa5429() { - f16vec3 res = pow(f16vec3(1.0hf), f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void pow_fa5429() { - f16vec3 res = pow(f16vec3(1.0hf), f16vec3(1.0hf)); + f16vec3 res = f16vec3(1.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.msl b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.msl index 220abc46a0..2148fc7d6d 100644 --- a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void pow_fa5429() { - half3 res = pow(half3(1.0h), half3(1.0h)); + half3 res = half3(1.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.spvasm index 68917f87df..5ad9738ba5 100644 --- a/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/pow/fa5429.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -38,37 +37,36 @@ %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 %half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 + %16 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %pow_fa5429 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Pow %18 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %pow_fa5429 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %pow_fa5429 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %pow_fa5429 + %29 = OpLabel + %30 = OpFunctionCall %void %pow_fa5429 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %pow_fa5429 + %32 = OpLabel + %33 = OpFunctionCall %void %pow_fa5429 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/pow/749c42.wgsl b/test/tint/builtins/gen/var/pow/749c42.wgsl new file mode 100644 index 0000000000..28a6356e54 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.wgsl @@ -0,0 +1,45 @@ +// 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 pow(fa, fa) -> fa +fn pow_749c42() { + const arg_0 = 1.; + const arg_1 = 1.; + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_749c42(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_749c42(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_749c42(); +} diff --git a/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..ecbf0c07b4 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_749c42() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_749c42(); + 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() { + pow_749c42(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_749c42(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..ecbf0c07b4 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_749c42() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_749c42(); + 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() { + pow_749c42(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_749c42(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.glsl b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.glsl new file mode 100644 index 0000000000..d61fbdb455 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_749c42() { + float res = 1.0f; +} + +vec4 vertex_main() { + pow_749c42(); + 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 pow_749c42() { + float res = 1.0f; +} + +void fragment_main() { + pow_749c42(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_749c42() { + float res = 1.0f; +} + +void compute_main() { + pow_749c42(); +} + +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/pow/749c42.wgsl.expected.msl b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.msl new file mode 100644 index 0000000000..5aa140a06f --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_749c42() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_749c42(); + 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() { + pow_749c42(); + return; +} + +kernel void compute_main() { + pow_749c42(); + return; +} + diff --git a/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.spvasm b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.spvasm new file mode 100644 index 0000000000..52a393b96c --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.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 %pow_749c42 "pow_749c42" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %pow_749c42 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %pow_749c42 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %pow_749c42 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_749c42 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.wgsl b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.wgsl new file mode 100644 index 0000000000..dab5398bcf --- /dev/null +++ b/test/tint/builtins/gen/var/pow/749c42.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn pow_749c42() { + const arg_0 = 1.0; + const arg_1 = 1.0; + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_749c42(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_749c42(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_749c42(); +} diff --git a/test/tint/builtins/gen/var/pow/a8f6b2.wgsl b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl new file mode 100644 index 0000000000..97038eeb06 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl @@ -0,0 +1,45 @@ +// 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 pow(vec<4, fa>, vec<4, fa>) -> vec<4, fa> +fn pow_a8f6b2() { + const arg_0 = vec4(1.); + const arg_1 = vec4(1.); + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_a8f6b2(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_a8f6b2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_a8f6b2(); +} diff --git a/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a36a572fc0 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_a8f6b2() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_a8f6b2(); + 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() { + pow_a8f6b2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_a8f6b2(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a36a572fc0 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_a8f6b2() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_a8f6b2(); + 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() { + pow_a8f6b2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_a8f6b2(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.glsl b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.glsl new file mode 100644 index 0000000000..d5d0cf0c79 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_a8f6b2() { + vec4 res = vec4(1.0f); +} + +vec4 vertex_main() { + pow_a8f6b2(); + 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 pow_a8f6b2() { + vec4 res = vec4(1.0f); +} + +void fragment_main() { + pow_a8f6b2(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_a8f6b2() { + vec4 res = vec4(1.0f); +} + +void compute_main() { + pow_a8f6b2(); +} + +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/pow/a8f6b2.wgsl.expected.msl b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.msl new file mode 100644 index 0000000000..36e1b89214 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_a8f6b2() { + float4 res = float4(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_a8f6b2(); + 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() { + pow_a8f6b2(); + return; +} + +kernel void compute_main() { + pow_a8f6b2(); + return; +} + diff --git a/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.spvasm b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.spvasm new file mode 100644 index 0000000000..32d0af3c2b --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %pow_a8f6b2 "pow_a8f6b2" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_1 = OpConstant %float 1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %pow_a8f6b2 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %pow_a8f6b2 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %pow_a8f6b2 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %pow_a8f6b2 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.wgsl b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.wgsl new file mode 100644 index 0000000000..3c71ff7e8c --- /dev/null +++ b/test/tint/builtins/gen/var/pow/a8f6b2.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn pow_a8f6b2() { + const arg_0 = vec4(1.0); + const arg_1 = vec4(1.0); + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_a8f6b2(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_a8f6b2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_a8f6b2(); +} diff --git a/test/tint/builtins/gen/var/pow/bc91ed.wgsl b/test/tint/builtins/gen/var/pow/bc91ed.wgsl new file mode 100644 index 0000000000..e3891cf195 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl @@ -0,0 +1,45 @@ +// 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 pow(vec<2, fa>, vec<2, fa>) -> vec<2, fa> +fn pow_bc91ed() { + const arg_0 = vec2(1.); + const arg_1 = vec2(1.); + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_bc91ed(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_bc91ed(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_bc91ed(); +} diff --git a/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..2b5dc1c210 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_bc91ed() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_bc91ed(); + 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() { + pow_bc91ed(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_bc91ed(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..2b5dc1c210 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_bc91ed() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_bc91ed(); + 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() { + pow_bc91ed(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_bc91ed(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.glsl b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.glsl new file mode 100644 index 0000000000..892ea2e097 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_bc91ed() { + vec2 res = vec2(1.0f); +} + +vec4 vertex_main() { + pow_bc91ed(); + 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 pow_bc91ed() { + vec2 res = vec2(1.0f); +} + +void fragment_main() { + pow_bc91ed(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_bc91ed() { + vec2 res = vec2(1.0f); +} + +void compute_main() { + pow_bc91ed(); +} + +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/pow/bc91ed.wgsl.expected.msl b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.msl new file mode 100644 index 0000000000..47cfcb236b --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_bc91ed() { + float2 res = float2(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_bc91ed(); + 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() { + pow_bc91ed(); + return; +} + +kernel void compute_main() { + pow_bc91ed(); + return; +} + diff --git a/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.spvasm b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.spvasm new file mode 100644 index 0000000000..543384177b --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %pow_bc91ed "pow_bc91ed" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v2float %float_1 %float_1 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %pow_bc91ed = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %pow_bc91ed + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_bc91ed + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_bc91ed + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.wgsl b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.wgsl new file mode 100644 index 0000000000..fee550e394 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/bc91ed.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn pow_bc91ed() { + const arg_0 = vec2(1.0); + const arg_1 = vec2(1.0); + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_bc91ed(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_bc91ed(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_bc91ed(); +} diff --git a/test/tint/builtins/gen/var/pow/e42f20.wgsl b/test/tint/builtins/gen/var/pow/e42f20.wgsl new file mode 100644 index 0000000000..48cbde995e --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl @@ -0,0 +1,45 @@ +// 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 pow(vec<3, fa>, vec<3, fa>) -> vec<3, fa> +fn pow_e42f20() { + const arg_0 = vec3(1.); + const arg_1 = vec3(1.); + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_e42f20(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_e42f20(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_e42f20(); +} diff --git a/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a46c9fa0b9 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void pow_e42f20() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_e42f20(); + 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() { + pow_e42f20(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_e42f20(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a46c9fa0b9 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void pow_e42f20() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + pow_e42f20(); + 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() { + pow_e42f20(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + pow_e42f20(); + return; +} diff --git a/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.glsl b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.glsl new file mode 100644 index 0000000000..576ef1f5e9 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void pow_e42f20() { + vec3 res = vec3(1.0f); +} + +vec4 vertex_main() { + pow_e42f20(); + 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 pow_e42f20() { + vec3 res = vec3(1.0f); +} + +void fragment_main() { + pow_e42f20(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void pow_e42f20() { + vec3 res = vec3(1.0f); +} + +void compute_main() { + pow_e42f20(); +} + +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/pow/e42f20.wgsl.expected.msl b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.msl new file mode 100644 index 0000000000..c5703d09f9 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void pow_e42f20() { + float3 res = float3(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + pow_e42f20(); + 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() { + pow_e42f20(); + return; +} + +kernel void compute_main() { + pow_e42f20(); + return; +} + diff --git a/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.spvasm b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.spvasm new file mode 100644 index 0000000000..6386fcf687 --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %pow_e42f20 "pow_e42f20" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 + %float_1 = OpConstant %float 1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %pow_e42f20 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %pow_e42f20 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %pow_e42f20 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %pow_e42f20 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.wgsl b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.wgsl new file mode 100644 index 0000000000..a9f08dd4bf --- /dev/null +++ b/test/tint/builtins/gen/var/pow/e42f20.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn pow_e42f20() { + const arg_0 = vec3(1.0); + const arg_1 = vec3(1.0); + var res = pow(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + pow_e42f20(); + return vec4(); +} + +@fragment +fn fragment_main() { + pow_e42f20(); +} + +@compute @workgroup_size(1) +fn compute_main() { + pow_e42f20(); +}