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