mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
RDTSC-based glcycle_t for macOS
Time profiler implementation is now closer to Windows version
This commit is contained in:
parent
1cdfcb4935
commit
b12c8a8f79
3 changed files with 24 additions and 17 deletions
|
@ -40,6 +40,8 @@
|
|||
#include <intrin.h>
|
||||
|
||||
#define USE_WINDOWS_DWORD
|
||||
#elif defined __APPLE__
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "i_system.h"
|
||||
|
@ -114,6 +116,15 @@ void gl_CalculateCPUSpeed ()
|
|||
gl_SecondsPerCycle = 1.0 / CyclesPerSecond;
|
||||
gl_MillisecPerCycle = 1000.0 / CyclesPerSecond;
|
||||
}
|
||||
#elif defined __APPLE__
|
||||
long long frequency;
|
||||
size_t size = sizeof frequency;
|
||||
|
||||
if (0 == sysctlbyname("machdep.tsc.frequency", &frequency, &size, nullptr, 0) && 0 != frequency)
|
||||
{
|
||||
gl_SecondsPerCycle = 1.0 / frequency;
|
||||
gl_MillisecPerCycle = 1000.0 / frequency;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
extern bool gl_benching;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
extern double gl_SecondsPerCycle;
|
||||
extern double gl_MillisecPerCycle;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
__forceinline long long GetClockCycle ()
|
||||
{
|
||||
#if _M_X64
|
||||
|
@ -21,10 +21,14 @@ __forceinline long long GetClockCycle ()
|
|||
#endif
|
||||
}
|
||||
|
||||
#elif defined(__GNUG__) && defined(__i386__)
|
||||
#elif defined __APPLE__ && (defined __i386__ || defined __x86_64__)
|
||||
|
||||
extern double gl_SecondsPerCycle;
|
||||
extern double gl_MillisecPerCycle;
|
||||
inline long long GetClockCycle()
|
||||
{
|
||||
return __builtin_ia32_rdtsc();
|
||||
}
|
||||
|
||||
#elif defined(__GNUG__) && defined(__i386__)
|
||||
|
||||
inline long long GetClockCycle()
|
||||
{
|
||||
|
@ -42,21 +46,12 @@ inline long long GetClockCycle()
|
|||
|
||||
#else
|
||||
|
||||
extern double gl_SecondsPerCycle;
|
||||
extern double gl_MillisecPerCycle;
|
||||
|
||||
inline long long GetClockCycle ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (__APPLE__)
|
||||
|
||||
typedef cycle_t glcycle_t;
|
||||
|
||||
#else // !__APPLE__
|
||||
|
||||
class glcycle_t
|
||||
{
|
||||
public:
|
||||
|
@ -100,8 +95,6 @@ private:
|
|||
long long Counter;
|
||||
};
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
extern glcycle_t RenderWall,SetupWall,ClipWall;
|
||||
extern glcycle_t RenderFlat,SetupFlat;
|
||||
extern glcycle_t RenderSprite,SetupSprite;
|
||||
|
|
|
@ -534,6 +534,9 @@ CocoaVideo::CocoaVideo()
|
|||
{
|
||||
memset(&m_modeIterator, 0, sizeof m_modeIterator);
|
||||
|
||||
extern void gl_CalculateCPUSpeed();
|
||||
gl_CalculateCPUSpeed();
|
||||
|
||||
// Create OpenGL pixel format
|
||||
|
||||
NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(OpenGLProfile::Core);
|
||||
|
|
Loading…
Reference in a new issue