FPFlushDenormals.h 945 B

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