FPFlushDenormals.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/Core/FPControlWord.h>
  6. JPH_NAMESPACE_BEGIN
  7. #if defined(JPH_CPU_WASM) || defined(JPH_CPU_RISCV) || defined(JPH_CPU_PPC) || defined(JPH_CPU_LOONGARCH)
  8. // Not supported
  9. class FPFlushDenormals { };
  10. #elif defined(JPH_USE_SSE)
  11. /// Helper class that needs to be put on the stack to enable flushing denormals to zero
  12. /// This can make floating point operations much faster when working with very small numbers
  13. class FPFlushDenormals : public FPControlWord<_MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_MASK> { };
  14. #elif defined(JPH_CPU_ARM) && defined(JPH_COMPILER_MSVC)
  15. /// Helper class that needs to be put on the stack to enable flushing denormals to zero
  16. /// This can make floating point operations much faster when working with very small numbers
  17. class FPFlushDenormals : public FPControlWord<_DN_FLUSH, _MCW_DN> { };
  18. #elif defined(JPH_CPU_ARM)
  19. /// Flush denormals to zero bit
  20. static constexpr uint64 FP_FZ = 1 << 24;
  21. /// Helper class that needs to be put on the stack to enable flushing denormals to zero
  22. /// This can make floating point operations much faster when working with very small numbers
  23. class FPFlushDenormals : public FPControlWord<FP_FZ, FP_FZ> { };
  24. #else
  25. #error Unsupported CPU architecture
  26. #endif
  27. JPH_NAMESPACE_END