|
|
@ -62,8 +62,8 @@ |
|
|
|
* #define SUPPORT_BUSY_WAIT_LOOP |
|
|
|
* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used |
|
|
|
* |
|
|
|
* #define SUPPORT_HALFBUSY_WAIT_LOOP |
|
|
|
* Use a half-busy wait loop, in this case frame sleeps for some time and runs a busy-wait-loop at the end |
|
|
|
* #define SUPPORT_PARTIALBUSY_WAIT_LOOP |
|
|
|
* Use a partial-busy wait loop, in this case frame sleeps for most of the time and runs a busy-wait-loop at the end |
|
|
|
* |
|
|
|
* #define SUPPORT_EVENTS_WAITING |
|
|
|
* Wait for events passively (sleeping while no events) instead of polling them actively every frame |
|
|
@ -4550,10 +4550,15 @@ static void Wait(float ms) |
|
|
|
// Busy wait loop |
|
|
|
while ((nextTime - prevTime) < ms/1000.0f) nextTime = GetTime(); |
|
|
|
#else |
|
|
|
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP) |
|
|
|
#define MAX_HALFBUSY_WAIT_TIME 4 |
|
|
|
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) |
|
|
|
#define DEFAULT_PARTIALBUSY_WAIT_TIME 4 |
|
|
|
#define PARTIALBUSY_WAIT_FACTOR 0.95f |
|
|
|
float halfWait = DEFAULT_PARTIALBUSY_WAIT_TIME; |
|
|
|
if (CORE.Time.target > 0) |
|
|
|
halfWait = CORE.Time.target * PARTIALBUSY_WAIT_FACTOR; |
|
|
|
|
|
|
|
double destTime = GetTime() + ms/1000; |
|
|
|
if (ms > MAX_HALFBUSY_WAIT_TIME) ms -= MAX_HALFBUSY_WAIT_TIME; |
|
|
|
if (ms > halfWait) ms -= halfWait; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(_WIN32) |
|
|
@ -4573,7 +4578,7 @@ static void Wait(float ms) |
|
|
|
usleep(ms*1000.0f); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP) |
|
|
|
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) |
|
|
|
while (GetTime() < destTime) { } |
|
|
|
#endif |
|
|
|
#endif |
|
|
|