apple platform improvements

This commit is contained in:
János Turánszki
2026-01-14 17:32:44 +01:00
parent 8f3e05f933
commit d4bb05ae25
4 changed files with 34 additions and 9 deletions
+19
View File
@@ -28,6 +28,10 @@
#include "wiJobSystem_PS5.h"
#endif // PLATFORM_PS5
#ifdef __APPLE__
#include <sys/qos.h>
#endif // __APPLE__
namespace wi::jobsystem
{
struct alignas(64) Job
@@ -306,6 +310,21 @@ namespace wi::jobsystem
default:
assert(0);
}
#elif defined(__APPLE__)
switch (priority)
{
case Priority::High:
pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
break;
case Priority::Low:
pthread_set_qos_class_self_np(QOS_CLASS_UTILITY, 0);
break;
case Priority::Streaming:
pthread_set_qos_class_self_np(QOS_CLASS_BACKGROUND, 0);
break;
default:
assert(0);
}
#endif // PLATFORM_LINUX
while (internal_state.alive.load(std::memory_order_relaxed))
+1 -1
View File
@@ -71,7 +71,7 @@ namespace wi::platform
SDL_Event quit_event;
quit_event.type = SDL_QUIT;
SDL_PushEvent(&quit_event);
#else
#elif defined(__APPLE__)
std::exit(0);
#endif
+13 -7
View File
@@ -3,16 +3,17 @@
#include <thread>
#if defined(_M_ARM64) || defined(__arm64__)
#include <mutex>
#ifdef _WIN32
#include <intrin.h> // __yield()
#else
#include <arm_acle.h> // __yield()
#endif // _WIN32
#else
#include <emmintrin.h> // _mm_pause()
#endif // efined(_M_ARM64) || defined(__arm64__)
namespace wi
{
#if defined(_M_ARM64) || defined(__arm64__)
using SpinLock = std::mutex;
#else
class SpinLock
{
private:
@@ -25,11 +26,17 @@ namespace wi
{
if (spin < 10)
{
_mm_pause(); // SMT thread swap can occur here
// SMT thread swap can occur here:
#if defined(_M_ARM64) || defined(__arm64__)
__yield();
#else
_mm_pause();
#endif // defined(_M_ARM64) || defined(__arm64__)
}
else
{
std::this_thread::yield(); // OS thread swap can occur here. It is important to keep it as fallback, to avoid any chance of lockup by busy wait
// OS thread swap can occur here. It is important to keep it as fallback, to avoid any chance of lockup by busy wait
std::this_thread::yield();
}
spin++;
}
@@ -44,5 +51,4 @@ namespace wi
lck.clear(std::memory_order_release);
}
};
#endif // efined(_M_ARM64) || defined(__arm64__)
}
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 72;
// minor bug fixes, alterations, refactors, updates
const int revision = 2;
const int revision = 3;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);