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#endif
13
15
16#if defined(JPH_PLATFORM_WINDOWS_UWP) || (defined(JPH_PLATFORM_WINDOWS) && defined(JPH_CPU_ARM))
17
19uint64 GetProcessorTickCount(); // Not inline to avoid having to include Windows.h
20
21#else
22
25{
26#if defined(JPH_PLATFORM_BLUE)
27 return JPH_PLATFORM_BLUE_GET_TICKS();
28#elif defined(JPH_CPU_X86)
29 return __rdtsc();
30#elif defined(JPH_CPU_ARM) && defined(JPH_USE_NEON)
31 uint64 val;
32 asm volatile("mrs %0, cntvct_el0" : "=r" (val));
33 return val;
34#elif defined(JPH_CPU_ARM)
35 return 0; // Not supported
36#elif defined(JPH_CPU_WASM)
37 return 0; // Not supported
38#else
39 #error Undefined
40#endif
41}
42
43#endif // JPH_PLATFORM_WINDOWS_UWP || (JPH_PLATFORM_WINDOWS && JPH_CPU_ARM)
44
std::uint64_t uint64
Definition: Core.h:430
#define JPH_NAMESPACE_END
Definition: Core.h:354
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:348
JPH_NAMESPACE_BEGIN JPH_INLINE uint64 GetProcessorTickCount()
Functionality to get the processors cycle counter.
Definition: TickCounter.h:24