mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 15:02:39 +00:00
- Run down the semaphores so they behave more like a mutex (note: mutexes/condition variables seem to be much slower).
- Fixed: vid_maxfps and cl_capfps could run into a deadlock on Linux based operating systems. SVN r3900 (trunk)
This commit is contained in:
parent
cd2c1f6816
commit
3ec5f7ed88
3 changed files with 20 additions and 13 deletions
|
@ -190,10 +190,10 @@ void I_ClosestResolution (int *width, int *height, int bits)
|
||||||
// Pass a negative value for the limit to use the value of vid_maxfps.
|
// Pass a negative value for the limit to use the value of vid_maxfps.
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
EXTERN_CVAR(Int, vid_maxfps);
|
EXTERN_CVAR(Int, vid_maxfps);
|
||||||
EXTERN_CVAR(Bool, cl_capfps);
|
EXTERN_CVAR(Bool, cl_capfps);
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
Semaphore FPSLimitSemaphore;
|
Semaphore FPSLimitSemaphore;
|
||||||
|
|
||||||
|
@ -245,13 +245,13 @@ void I_SetFPSLimit(int limit)
|
||||||
Printf("Failed to set FPS limitter timer\n");
|
Printf("Failed to set FPS limitter timer\n");
|
||||||
DPrintf("FPS timer set to %u ms\n", (unsigned int) period.it_interval.tv_nsec / 1000000);
|
DPrintf("FPS timer set to %u ms\n", (unsigned int) period.it_interval.tv_nsec / 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// So Apple doesn't support POSIX timers and I can't find a good substitute short of
|
// So Apple doesn't support POSIX timers and I can't find a good substitute short of
|
||||||
// having Objective-C Cocoa events or something like that.
|
// having Objective-C Cocoa events or something like that.
|
||||||
void I_SetFPSLimit(int limit)
|
void I_SetFPSLimit(int limit)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
|
|
@ -53,7 +53,13 @@ typedef semaphore_t Semaphore;
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
typedef sem_t Semaphore;
|
typedef sem_t Semaphore;
|
||||||
#define SEMAPHORE_WAIT(sem) \
|
#define SEMAPHORE_WAIT(sem) \
|
||||||
while(sem_wait(&sem) != 0);
|
do { \
|
||||||
|
while(sem_wait(&sem) != 0); \
|
||||||
|
int semValue; \
|
||||||
|
sem_getvalue(&sem, &semValue); \
|
||||||
|
if(semValue < 1) \
|
||||||
|
break; \
|
||||||
|
} while(true);
|
||||||
#define SEMAPHORE_SIGNAL(sem) \
|
#define SEMAPHORE_SIGNAL(sem) \
|
||||||
sem_post(&sem);
|
sem_post(&sem);
|
||||||
#define SEMAPHORE_INIT(sem, shared, value) \
|
#define SEMAPHORE_INIT(sem, shared, value) \
|
||||||
|
|
|
@ -81,6 +81,7 @@ extern bool GUICapture;
|
||||||
|
|
||||||
EXTERN_CVAR (Float, Gamma)
|
EXTERN_CVAR (Float, Gamma)
|
||||||
EXTERN_CVAR (Int, vid_maxfps)
|
EXTERN_CVAR (Int, vid_maxfps)
|
||||||
|
EXTERN_CVAR (Bool, cl_capfps)
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
|
|
||||||
|
@ -374,12 +375,12 @@ void SDLFB::Update ()
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawRateStuff ();
|
DrawRateStuff ();
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
if(vid_maxfps)
|
if(vid_maxfps && !cl_capfps)
|
||||||
{
|
{
|
||||||
SEMAPHORE_WAIT(FPSLimitSemaphore)
|
SEMAPHORE_WAIT(FPSLimitSemaphore)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
|
|
Loading…
Reference in a new issue