diff --git a/Source/Engine/Platform/Android/AndroidPlatform.h b/Source/Engine/Platform/Android/AndroidPlatform.h index 2d40c709f..4bae040cc 100644 --- a/Source/Engine/Platform/Android/AndroidPlatform.h +++ b/Source/Engine/Platform/Android/AndroidPlatform.h @@ -30,6 +30,10 @@ public: { __sync_synchronize(); } + FORCE_INLINE static void MemoryPrefetch(void const* ptr) + { + __builtin_prefetch(static_cast(ptr)); + } FORCE_INLINE static int64 InterlockedExchange(int64 volatile* dst, int64 exchange) { return __sync_lock_test_and_set(dst, exchange); @@ -74,10 +78,6 @@ public: { __atomic_store(dst, &value, __ATOMIC_RELAXED); } - FORCE_INLINE static void Prefetch(void const* ptr) - { - __builtin_prefetch(static_cast(ptr)); - } static bool Is64BitPlatform(); static String GetSystemName(); static Version GetSystemVersion(); diff --git a/Source/Engine/Platform/Apple/ApplePlatform.h b/Source/Engine/Platform/Apple/ApplePlatform.h index cf91b8e22..02f6ac347 100644 --- a/Source/Engine/Platform/Apple/ApplePlatform.h +++ b/Source/Engine/Platform/Apple/ApplePlatform.h @@ -21,6 +21,10 @@ public: { __sync_synchronize(); } + FORCE_INLINE static void MemoryPrefetch(void const* ptr) + { + __builtin_prefetch(static_cast(ptr)); + } FORCE_INLINE static int64 InterlockedExchange(int64 volatile* dst, int64 exchange) { return __sync_lock_test_and_set(dst, exchange); @@ -62,9 +66,6 @@ public: __atomic_store_n((volatile int64*)dst, value, __ATOMIC_RELAXED); } FORCE_INLINE static void Prefetch(void const* ptr) - { - __builtin_prefetch(static_cast(ptr)); - } static bool Is64BitPlatform(); static String GetSystemName(); static Version GetSystemVersion(); diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index ff47e77a3..eeaeb879d 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -239,6 +239,12 @@ public: /// static void MemoryBarrier() = delete; + /// + /// Indicates to the processor that a cache line will be needed in the near future. + /// + /// The address of the cache line to be loaded. This address is not required to be on a cache line boundary. + static void Prefetch(void const* ptr) = delete; + /// /// Sets a 64-bit variable to the specified value as an atomic operation. The function prevents more than one thread from using the same variable simultaneously. /// @@ -317,12 +323,6 @@ public: /// The value to be set. static void AtomicStore(int64 volatile* dst, int64 value) = delete; - /// - /// Indicates to the processor that a cache line will be needed in the near future. - /// - /// The address of the cache line to be loaded. This address is not required to be on a cache line boundary. - static void Prefetch(void const* ptr) = delete; - #if COMPILE_WITH_PROFILER static void OnMemoryAlloc(void* ptr, uint64 size); static void OnMemoryFree(void* ptr); diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.h b/Source/Engine/Platform/Linux/LinuxPlatform.h index 08637dc87..98d9d2976 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.h +++ b/Source/Engine/Platform/Linux/LinuxPlatform.h @@ -45,6 +45,10 @@ public: { __sync_synchronize(); } + FORCE_INLINE static void MemoryPrefetch(void const* ptr) + { + __builtin_prefetch(static_cast(ptr)); + } FORCE_INLINE static int64 InterlockedExchange(int64 volatile* dst, int64 exchange) { return __sync_lock_test_and_set(dst, exchange); @@ -89,10 +93,6 @@ public: { __atomic_store(dst, &value, __ATOMIC_SEQ_CST); } - FORCE_INLINE static void Prefetch(void const* ptr) - { - __builtin_prefetch(static_cast(ptr)); - } static bool Is64BitPlatform(); static String GetSystemName(); static Version GetSystemVersion(); diff --git a/Source/Engine/Platform/Win32/Win32Platform.cpp b/Source/Engine/Platform/Win32/Win32Platform.cpp index c002986c9..d32cb1249 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.cpp +++ b/Source/Engine/Platform/Win32/Win32Platform.cpp @@ -251,7 +251,7 @@ void Win32Platform::MemoryBarrier() #endif } -void Win32Platform::Prefetch(void const* ptr) +void Win32Platform::MemoryPrefetch(void const* ptr) { #if _M_ARM64 __prefetch((char const*)ptr); diff --git a/Source/Engine/Platform/Win32/Win32Platform.h b/Source/Engine/Platform/Win32/Win32Platform.h index 5763641ee..36d982bf7 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.h +++ b/Source/Engine/Platform/Win32/Win32Platform.h @@ -23,6 +23,7 @@ public: static bool Init(); static void Exit(); static void MemoryBarrier(); + static void MemoryPrefetch(void const* ptr); static int64 InterlockedExchange(int64 volatile* dst, int64 exchange) { #if WIN64 @@ -83,7 +84,6 @@ public: _interlockedexchange64(dst, value); #endif } - static void Prefetch(void const* ptr); static void* Allocate(uint64 size, uint64 alignment); static void Free(void* ptr); static void* AllocatePages(uint64 numPages, uint64 pageSize);