FPFlushDenormals.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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)
  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. class FPFlushDenormals : public FPControlWord<_DN_FLUSH, _MCW_DN> { };
  16. #elif defined(JPH_CPU_ARM)
  17. /// Flush denormals to zero bit
  18. static constexpr uint64 FP_FZ = 1 << 24;
  19. /// Helper class that needs to be put on the stack to enable flushing denormals to zero
  20. /// This can make floating point operations much faster when working with very small numbers
  21. class FPFlushDenormals : public FPControlWord<FP_FZ, FP_FZ> { };
  22. #else
  23. #error Unsupported CPU architecture
  24. #endif
  25. JPH_NAMESPACE_END