| 607 | class Module_Math : public Module { |
| 608 | public: |
| 609 | Module_Math() : Module("math") { |
| 610 | DAS_PROFILE_SECTION("Module_Math"); |
| 611 | ModuleLibrary lib(this); |
| 612 | lib.addBuiltInModule(); |
| 613 | // constants |
| 614 | addConstant(*this,"PI",(float)M_PI); |
| 615 | addConstant(*this,"DBL_PI",(double)M_PI); |
| 616 | addConstant(*this,"FLT_EPSILON",FLT_EPSILON); |
| 617 | addConstant(*this,"DBL_EPSILON",DBL_EPSILON); |
| 618 | // trigonometry functions |
| 619 | addFunctionTrig<float>(*this, lib); |
| 620 | addFunctionTrig<float2>(*this,lib); |
| 621 | addFunctionTrig<float3>(*this,lib); |
| 622 | addFunctionTrig<float4>(*this,lib); |
| 623 | // exp functions |
| 624 | addFunctionPow<float>(*this, lib); |
| 625 | addFunctionPow<float2>(*this,lib); |
| 626 | addFunctionPow<float3>(*this,lib); |
| 627 | addFunctionPow<float4>(*this,lib); |
| 628 | // op3 |
| 629 | addFunctionOp3<float >(*this,lib); |
| 630 | addFunctionOp3<float2>(*this,lib); |
| 631 | addFunctionOp3<float3>(*this,lib); |
| 632 | addFunctionOp3<float4>(*this,lib); |
| 633 | addFunction( (new BuiltInFn<Sim_MadS<float2>, float2, float2, float, float2>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 634 | addFunction( (new BuiltInFn<Sim_MadS<float3>, float3, float3, float, float3>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 635 | addFunction( (new BuiltInFn<Sim_MadS<float4>, float4, float4, float, float4>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 636 | // op3i - int |
| 637 | addFunctionOp3i<int32_t >(*this,lib); |
| 638 | addFunctionOp3i<int2>(*this,lib); |
| 639 | addFunctionOp3i<int3>(*this,lib); |
| 640 | addFunctionOp3i<int4>(*this,lib); |
| 641 | addFunction( (new BuiltInFn<Sim_MadS<int2>, int2, int2, int, int2>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 642 | addFunction( (new BuiltInFn<Sim_MadS<int3>, int3, int3, int, int3>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 643 | addFunction( (new BuiltInFn<Sim_MadS<int4>, int4, int4, int, int4>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 644 | // op3i - uint |
| 645 | addFunctionOp3i<uint32_t>(*this,lib); |
| 646 | addFunctionOp3i<uint2>(*this,lib); |
| 647 | addFunctionOp3i<uint3>(*this,lib); |
| 648 | addFunctionOp3i<uint4>(*this,lib); |
| 649 | addFunction( (new BuiltInFn<Sim_MadS<uint2>, uint2, uint2, uint32_t, uint2>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 650 | addFunction( (new BuiltInFn<Sim_MadS<uint3>, uint3, uint3, uint32_t, uint3>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 651 | addFunction( (new BuiltInFn<Sim_MadS<uint4>, uint4, uint4, uint32_t, uint4>("mad", lib, "MadS"))->args({"a","b","c"}) ); |
| 652 | // and double |
| 653 | addFunctionOp3<double>(*this,lib); |
| 654 | // double common (sqrt/rsqrt/rcp already registered as externs below) |
| 655 | addFunction( (new BuiltInFn<Sim_Floor<double>, double, double>("floor", lib, "Floor"))->arg("x") ); |
| 656 | addFunction( (new BuiltInFn<Sim_Ceil<double>, double, double>("ceil", lib, "Ceil"))->arg("x") ); |
| 657 | addFunction( (new BuiltInFn<Sim_Fract<double>, double, double>("fract", lib, "Fract"))->arg("x") ); |
| 658 | addFunction( (new BuiltInFn<Sim_Round<double>, double, double>("round", lib, "Round"))->arg("x") ); |
| 659 | addFunction( (new BuiltInFn<Sim_Sat<double>, double, double>("saturate", lib, "Sat"))->arg("x") ); |
| 660 | //common |
| 661 | addFunctionCommon<float>(*this, lib); |
| 662 | addFunctionCommon<float2>(*this,lib); |
| 663 | addFunctionCommon<float3>(*this,lib); |
| 664 | addFunctionCommon<float4>(*this,lib); |
| 665 | addFunctionCommonTyped<int32_t>(*this, lib); |
| 666 | addFunctionCommonTyped<int2>(*this, lib); |
nothing calls this directly
no test coverage detected