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