Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
TickCounter.h
Go to the documentation of this file.
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 for __rdtsc
8#if defined(JPH_PLATFORM_WINDOWS)
9 #include <intrin.h>
10#elif defined(JPH_CPU_X86) && defined(JPH_COMPILER_GCC)
11 #include <x86intrin.h>
12#elif defined(JPH_CPU_E2K)
13 #include <x86intrin.h>
14#endif
15
17
18#if defined(JPH_PLATFORM_WINDOWS_UWP) || (defined(JPH_PLATFORM_WINDOWS) && defined(JPH_CPU_ARM))
19
21uint64 GetProcessorTickCount(); // Not inline to avoid having to include Windows.h
22
23#else
24
27{
28#if defined(JPH_PLATFORM_BLUE)
29 return JPH_PLATFORM_BLUE_GET_TICKS();
30#elif defined(JPH_CPU_X86)
31 return __rdtsc();
32#elif defined(JPH_CPU_E2K)
33 return __rdtsc();
34#elif defined(JPH_CPU_ARM) && defined(JPH_USE_NEON)
35 uint64 val;
36 asm volatile("mrs %0, cntvct_el0" : "=r" (val));
37 return val;
38#elif defined(JPH_CPU_ARM)
39 return 0; // Not supported
40#elif defined(JPH_CPU_WASM)
41 return 0; // Not supported
42#else
43 #error Undefined
44#endif
45}
46
47#endif // JPH_PLATFORM_WINDOWS_UWP || (JPH_PLATFORM_WINDOWS && JPH_CPU_ARM)
48
std::uint64_t uint64
Definition: Core.h:456
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
JPH_NAMESPACE_BEGIN JPH_INLINE uint64 GetProcessorTickCount()
Functionality to get the processors cycle counter.
Definition: TickCounter.h:26