mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-24 22:34:54 +00:00
Fix ogl screenshots for windows.
Fix the macosx build (perhaps). This changes the JitIL timed profiling to using assembly language to obtain the time. It does seem to be faster. Not sure if it will work on macosx, but if it does it has the necessary precision that gettimeofday does not have. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6448 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ef55177ed6
commit
7788bac40c
5 changed files with 43 additions and 8 deletions
|
@ -492,11 +492,16 @@ namespace Common
|
||||||
|
|
||||||
if (timeout != INFINITE)
|
if (timeout != INFINITE)
|
||||||
{
|
{
|
||||||
|
memset(&wait, 0, sizeof(wait));
|
||||||
|
#ifdef USE_GETTIMEOFDAY
|
||||||
|
struct timeval now;
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
wait.tv_nsec = (now.tv_usec + (timeout % 1000)) * 1000;
|
||||||
|
#else
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||||
|
|
||||||
memset(&wait, 0, sizeof(wait));
|
|
||||||
wait.tv_nsec = now.tv_nsec + (timeout % 1000) * 1000000;
|
wait.tv_nsec = now.tv_nsec + (timeout % 1000) * 1000000;
|
||||||
|
#endif
|
||||||
wait.tv_sec = now.tv_sec + (timeout / 1000);
|
wait.tv_sec = now.tv_sec + (timeout / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,13 @@
|
||||||
#define INFINITE 0xffffffff
|
#define INFINITE 0xffffffff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//for clock_gettime and struct timespec
|
//for (clock_gettime|gettimeofday) and struct time(spec|val)
|
||||||
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#if !defined(_POSIX_TIMERS) || _POSIX_TIMERS == 0
|
||||||
|
#define USE_GETTIMEOFDAY
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#if !defined(_POSIX_TIMERS) || _POSIX_TIMERS == 0
|
||||||
|
#define USE_GETTIMEOFDAY
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
@ -34,6 +40,10 @@ u32 Timer::GetTimeMs()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return timeGetTime();
|
return timeGetTime();
|
||||||
|
#elif defined USE_GETTIMEOFDAY
|
||||||
|
struct timeval t;
|
||||||
|
(void)gettimeofday(&t, NULL);
|
||||||
|
return ((u32)(t.tv_sec * 1000 + t.tv_usec / 1000));
|
||||||
#else
|
#else
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &t);
|
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &t);
|
||||||
|
@ -203,6 +213,10 @@ std::string Timer::GetTimeFormatted()
|
||||||
struct timeb tp;
|
struct timeb tp;
|
||||||
(void)::ftime(&tp);
|
(void)::ftime(&tp);
|
||||||
sprintf(formattedTime, "%s:%03i", tmp, tp.millitm);
|
sprintf(formattedTime, "%s:%03i", tmp, tp.millitm);
|
||||||
|
#elif defined USE_GETTIMEOFDAY
|
||||||
|
struct timeval t;
|
||||||
|
(void)gettimeofday(&t, NULL);
|
||||||
|
sprintf(formattedTime, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
|
||||||
#else
|
#else
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
(void)clock_gettime(CLOCK_REALTIME, &t);
|
(void)clock_gettime(CLOCK_REALTIME, &t);
|
||||||
|
@ -219,6 +233,9 @@ double Timer::GetDoubleTime()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct timeb tp;
|
struct timeb tp;
|
||||||
(void)::ftime(&tp);
|
(void)::ftime(&tp);
|
||||||
|
#elif defined USE_GETTIMEOFDAY
|
||||||
|
struct timeval t;
|
||||||
|
(void)gettimeofday(&t, NULL);
|
||||||
#else
|
#else
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
(void)clock_gettime(CLOCK_REALTIME, &t);
|
(void)clock_gettime(CLOCK_REALTIME, &t);
|
||||||
|
@ -236,6 +253,8 @@ double Timer::GetDoubleTime()
|
||||||
u32 Seconds = (u32)TmpSeconds;
|
u32 Seconds = (u32)TmpSeconds;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
double ms = tp.millitm / 1000.0 / 1000.0;
|
double ms = tp.millitm / 1000.0 / 1000.0;
|
||||||
|
#elif defined USE_GETTIMEOFDAY
|
||||||
|
double ms = t.tv_usec / 1000000.0;
|
||||||
#else
|
#else
|
||||||
double ms = t.tv_nsec / 1000000000.0;
|
double ms = t.tv_nsec / 1000000000.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -162,12 +162,14 @@ ps_adds1
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#else
|
#else
|
||||||
#include <memory>
|
#include <memory>
|
||||||
static inline u64 __rdtsc()
|
#include <stdint.h>
|
||||||
|
static inline uint64_t __rdtsc()
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
uint32_t lo, hi;
|
||||||
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
__asm__ __volatile__ ("xorl %%eax,%%eax \n cpuid"
|
||||||
|
::: "%rax", "%rbx", "%rcx", "%rdx");
|
||||||
return (ts.tv_sec * 100000000 + ts.tv_nsec);
|
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
|
||||||
|
return (uint64_t)hi << 32 | lo;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,10 @@ void Initialize(void *init)
|
||||||
g_Config.GameIniLoad(globals->game_ini);
|
g_Config.GameIniLoad(globals->game_ini);
|
||||||
|
|
||||||
g_Config.UpdateProjectionHack();
|
g_Config.UpdateProjectionHack();
|
||||||
|
#if defined _WIN32
|
||||||
|
// Enable support for PNG screenshots.
|
||||||
|
wxImage::AddHandler( new wxPNGHandler );
|
||||||
|
#endif
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
|
|
||||||
if (!OpenGL_Create(g_VideoInitialize, 640, 480))
|
if (!OpenGL_Create(g_VideoInitialize, 640, 480))
|
||||||
|
|
Loading…
Add table
Reference in a new issue