mirror of https://github.com/PCSX2/pcsx2.git
zzogl-pg: Separate out some profile code.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2934 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
c160aa495a
commit
393963f578
|
@ -37,6 +37,7 @@ using namespace std;
|
|||
#include "GS.h"
|
||||
#include "Mem.h"
|
||||
#include "Regs.h"
|
||||
#include "Profile.h"
|
||||
|
||||
#include "zerogs.h"
|
||||
#include "targets.h"
|
||||
|
@ -92,12 +93,6 @@ extern int g_nPixelShaderVer;
|
|||
extern int g_nFrameRender;
|
||||
extern int g_nFramesSkipped;
|
||||
|
||||
#if !defined(ZEROGS_DEVBUILD)
|
||||
#define g_bWriteProfile 0
|
||||
#else
|
||||
bool g_bWriteProfile = 0;
|
||||
#endif
|
||||
|
||||
int s_frameskipping = 0;
|
||||
u32 CALLBACK PS2EgetLibType()
|
||||
{
|
||||
|
@ -114,8 +109,6 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type)
|
|||
return (zgsversion << 16) | (zgsrevision << 8) | zgsbuild | (zgsminor << 24);
|
||||
}
|
||||
|
||||
static u64 luPerfFreq;
|
||||
|
||||
GLWindow GLWin;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -1135,236 +1128,3 @@ s32 CALLBACK GSfreeze(int mode, freezeData *data)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Small profiler //
|
||||
////////////////////
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define GET_PROFILE_TIME() GetCPUTicks()
|
||||
|
||||
struct DVPROFSTRUCT;
|
||||
|
||||
struct DVPROFSTRUCT
|
||||
{
|
||||
|
||||
struct DATA
|
||||
{
|
||||
DATA(u64 time, u32 user = 0) : dwTime(time), dwUserData(user) {}
|
||||
|
||||
DATA() : dwTime(0), dwUserData(0) {}
|
||||
|
||||
u64 dwTime;
|
||||
u32 dwUserData;
|
||||
};
|
||||
|
||||
~DVPROFSTRUCT()
|
||||
{
|
||||
list<DVPROFSTRUCT*>::iterator it = listpChild.begin();
|
||||
|
||||
while (it != listpChild.end())
|
||||
{
|
||||
SAFE_DELETE(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
list<DATA> listTimes; // before DVProfEnd is called, contains the global time it started
|
||||
// after DVProfEnd is called, contains the time it lasted
|
||||
// the list contains all the tracked times
|
||||
char pname[256];
|
||||
|
||||
list<DVPROFSTRUCT*> listpChild; // other profilers called during this profiler period
|
||||
};
|
||||
|
||||
struct DVPROFTRACK
|
||||
{
|
||||
u32 dwUserData;
|
||||
DVPROFSTRUCT::DATA* pdwTime;
|
||||
DVPROFSTRUCT* pprof;
|
||||
};
|
||||
|
||||
list<DVPROFTRACK> g_listCurTracking; // the current profiling functions, the back element is the
|
||||
// one that will first get popped off the list when DVProfEnd is called
|
||||
// the pointer is an element in DVPROFSTRUCT::listTimes
|
||||
list<DVPROFSTRUCT> g_listProfilers; // the current profilers, note that these are the parents
|
||||
// any profiler started during the time of another is held in
|
||||
// DVPROFSTRUCT::listpChild
|
||||
list<DVPROFSTRUCT*> g_listAllProfilers; // ignores the hierarchy, pointer to elements in g_listProfilers
|
||||
|
||||
void DVProfRegister(char* pname)
|
||||
{
|
||||
if (!g_bWriteProfile)
|
||||
return;
|
||||
|
||||
list<DVPROFSTRUCT*>::iterator it = g_listAllProfilers.begin();
|
||||
|
||||
// while(it != g_listAllProfilers.end() ) {
|
||||
//
|
||||
// if( _tcscmp(pname, (*it)->pname) == 0 ) {
|
||||
// (*it)->listTimes.push_back(timeGetTime());
|
||||
// DVPROFTRACK dvtrack;
|
||||
// dvtrack.pdwTime = &(*it)->listTimes.back();
|
||||
// dvtrack.pprof = *it;
|
||||
// g_listCurTracking.push_back(dvtrack);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ++it;
|
||||
// }
|
||||
|
||||
// else add in a new profiler to the appropriate parent profiler
|
||||
DVPROFSTRUCT* pprof = NULL;
|
||||
|
||||
if (g_listCurTracking.size() > 0)
|
||||
{
|
||||
assert(g_listCurTracking.back().pprof != NULL);
|
||||
g_listCurTracking.back().pprof->listpChild.push_back(new DVPROFSTRUCT());
|
||||
pprof = g_listCurTracking.back().pprof->listpChild.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_listProfilers.push_back(DVPROFSTRUCT());
|
||||
pprof = &g_listProfilers.back();
|
||||
}
|
||||
|
||||
strncpy(pprof->pname, pname, 256);
|
||||
|
||||
// setup the profiler for tracking
|
||||
pprof->listTimes.push_back(DVPROFSTRUCT::DATA(GET_PROFILE_TIME()));
|
||||
|
||||
DVPROFTRACK dvtrack;
|
||||
dvtrack.pdwTime = &pprof->listTimes.back();
|
||||
dvtrack.pprof = pprof;
|
||||
dvtrack.dwUserData = 0;
|
||||
|
||||
g_listCurTracking.push_back(dvtrack);
|
||||
|
||||
// add to all profiler list
|
||||
g_listAllProfilers.push_back(pprof);
|
||||
}
|
||||
|
||||
void DVProfEnd(u32 dwUserData)
|
||||
{
|
||||
if (!g_bWriteProfile)
|
||||
return;
|
||||
|
||||
B_RETURN(g_listCurTracking.size() > 0);
|
||||
|
||||
DVPROFTRACK dvtrack = g_listCurTracking.back();
|
||||
|
||||
assert(dvtrack.pdwTime != NULL && dvtrack.pprof != NULL);
|
||||
|
||||
dvtrack.pdwTime->dwTime = 1000000 * (GET_PROFILE_TIME() - dvtrack.pdwTime->dwTime) / luPerfFreq;
|
||||
|
||||
dvtrack.pdwTime->dwUserData = dwUserData;
|
||||
|
||||
g_listCurTracking.pop_back();
|
||||
}
|
||||
|
||||
struct DVTIMEINFO
|
||||
{
|
||||
DVTIMEINFO() : uInclusive(0), uExclusive(0) {}
|
||||
|
||||
u64 uInclusive, uExclusive;
|
||||
};
|
||||
|
||||
map<string, DVTIMEINFO> mapAggregateTimes;
|
||||
|
||||
u64 DVProfWriteStruct(FILE* f, DVPROFSTRUCT* p, int ident)
|
||||
{
|
||||
fprintf(f, "%*s%s - ", ident, "", p->pname);
|
||||
|
||||
list<DVPROFSTRUCT::DATA>::iterator ittime = p->listTimes.begin();
|
||||
|
||||
u32 utime = 0;
|
||||
|
||||
while (ittime != p->listTimes.end())
|
||||
{
|
||||
utime += (u32)ittime->dwTime;
|
||||
|
||||
if (ittime->dwUserData)
|
||||
fprintf(f, "time: %d, user: 0x%8.8x", (u32)ittime->dwTime, ittime->dwUserData);
|
||||
else
|
||||
fprintf(f, "time: %d", (u32)ittime->dwTime);
|
||||
|
||||
++ittime;
|
||||
}
|
||||
|
||||
mapAggregateTimes[p->pname].uInclusive += utime;
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
list<DVPROFSTRUCT*>::iterator itprof = p->listpChild.begin();
|
||||
|
||||
u32 uex = utime;
|
||||
|
||||
while (itprof != p->listpChild.end())
|
||||
{
|
||||
|
||||
uex -= DVProfWriteStruct(f, *itprof, ident + 4);
|
||||
++itprof;
|
||||
}
|
||||
|
||||
mapAggregateTimes[p->pname].uExclusive += uex;
|
||||
|
||||
return utime;
|
||||
}
|
||||
|
||||
void DVProfWrite(char* pfilename, u32 frames)
|
||||
{
|
||||
assert(pfilename != NULL);
|
||||
FILE* f = fopen(pfilename, "wb");
|
||||
|
||||
mapAggregateTimes.clear();
|
||||
list<DVPROFSTRUCT>::iterator it = g_listProfilers.begin();
|
||||
|
||||
while (it != g_listProfilers.end())
|
||||
{
|
||||
DVProfWriteStruct(f, &(*it), 0);
|
||||
++it;
|
||||
}
|
||||
|
||||
{
|
||||
map<string, DVTIMEINFO>::iterator it;
|
||||
fprintf(f, "\n\n-------------------------------------------------------------------\n\n");
|
||||
|
||||
u64 uTotal[2] = {0};
|
||||
double fiTotalTime[2];
|
||||
|
||||
for (it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it)
|
||||
{
|
||||
uTotal[0] += it->second.uExclusive;
|
||||
uTotal[1] += it->second.uInclusive;
|
||||
}
|
||||
|
||||
fprintf(f, "total times (%d): ex: %Lu ", frames, uTotal[0] / frames);
|
||||
|
||||
fprintf(f, "inc: %Lu\n", uTotal[1] / frames);
|
||||
|
||||
fiTotalTime[0] = 1.0 / (double)uTotal[0];
|
||||
fiTotalTime[1] = 1.0 / (double)uTotal[1];
|
||||
|
||||
// output the combined times
|
||||
|
||||
for (it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it)
|
||||
{
|
||||
fprintf(f, "%s - ex: %f inc: %f\n", it->first.c_str(), (double)it->second.uExclusive * fiTotalTime[0],
|
||||
(double)it->second.uInclusive * fiTotalTime[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void DVProfClear()
|
||||
{
|
||||
g_listCurTracking.clear();
|
||||
g_listProfilers.clear();
|
||||
g_listAllProfilers.clear();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ libzzoglpg_LDFLAGS+=-Wl,-soname,@ZEROGS_SONAME@
|
|||
libzzoglpg_LDADD=$(libzzoglpg_a_OBJECTS)
|
||||
|
||||
libzzoglpg_a_SOURCES = \
|
||||
GSmain.cpp GLWinX11.cpp GifTransfer.cpp memcpy_amd.cpp Regs.cpp x86.cpp zpipe.cpp Mem.cpp \
|
||||
GSmain.cpp GLWinX11.cpp GifTransfer.cpp memcpy_amd.cpp Regs.cpp x86.cpp zpipe.cpp Mem.cpp Profile.cpp Profile.h \
|
||||
rasterfont.cpp targets.cpp zerogs.cpp ZZoglVB.cpp ZZoglShoots.cpp ZZoglCreate.cpp \
|
||||
ZZoglShaders.cpp ZZoglCRTC.cpp ZZoglSave.cpp ZZoglFlush.cpp \
|
||||
Mem_Swizzle.h Mem_Tables.cpp Mem_Transmit.h Mem_Swizzle.cpp
|
||||
|
|
|
@ -0,0 +1,259 @@
|
|||
/* ZeroGS KOSMOS
|
||||
* Copyright (C) 2005-2006 zerofrog@gmail.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
////////////////////
|
||||
// Small profiler //
|
||||
////////////////////
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "Profile.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define GET_PROFILE_TIME() GetCPUTicks()
|
||||
|
||||
#if !defined(ZEROGS_DEVBUILD)
|
||||
#define g_bWriteProfile 0
|
||||
#else
|
||||
bool g_bWriteProfile = 0;
|
||||
#endif
|
||||
|
||||
u64 luPerfFreq;
|
||||
|
||||
struct DVPROFSTRUCT;
|
||||
|
||||
struct DVPROFSTRUCT
|
||||
{
|
||||
|
||||
struct DATA
|
||||
{
|
||||
DATA(u64 time, u32 user = 0) : dwTime(time), dwUserData(user) {}
|
||||
|
||||
DATA() : dwTime(0), dwUserData(0) {}
|
||||
|
||||
u64 dwTime;
|
||||
u32 dwUserData;
|
||||
};
|
||||
|
||||
~DVPROFSTRUCT()
|
||||
{
|
||||
list<DVPROFSTRUCT*>::iterator it = listpChild.begin();
|
||||
|
||||
while (it != listpChild.end())
|
||||
{
|
||||
SAFE_DELETE(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
list<DATA> listTimes; // before DVProfEnd is called, contains the global time it started
|
||||
// after DVProfEnd is called, contains the time it lasted
|
||||
// the list contains all the tracked times
|
||||
char pname[256];
|
||||
|
||||
list<DVPROFSTRUCT*> listpChild; // other profilers called during this profiler period
|
||||
};
|
||||
|
||||
struct DVPROFTRACK
|
||||
{
|
||||
u32 dwUserData;
|
||||
DVPROFSTRUCT::DATA* pdwTime;
|
||||
DVPROFSTRUCT* pprof;
|
||||
};
|
||||
|
||||
list<DVPROFTRACK> g_listCurTracking; // the current profiling functions, the back element is the
|
||||
// one that will first get popped off the list when DVProfEnd is called
|
||||
// the pointer is an element in DVPROFSTRUCT::listTimes
|
||||
list<DVPROFSTRUCT> g_listProfilers; // the current profilers, note that these are the parents
|
||||
// any profiler started during the time of another is held in
|
||||
// DVPROFSTRUCT::listpChild
|
||||
list<DVPROFSTRUCT*> g_listAllProfilers; // ignores the hierarchy, pointer to elements in g_listProfilers
|
||||
|
||||
void DVProfRegister(char* pname)
|
||||
{
|
||||
if (!g_bWriteProfile) return;
|
||||
|
||||
list<DVPROFSTRUCT*>::iterator it = g_listAllProfilers.begin();
|
||||
|
||||
// while(it != g_listAllProfilers.end() ) {
|
||||
//
|
||||
// if( _tcscmp(pname, (*it)->pname) == 0 ) {
|
||||
// (*it)->listTimes.push_back(timeGetTime());
|
||||
// DVPROFTRACK dvtrack;
|
||||
// dvtrack.pdwTime = &(*it)->listTimes.back();
|
||||
// dvtrack.pprof = *it;
|
||||
// g_listCurTracking.push_back(dvtrack);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ++it;
|
||||
// }
|
||||
|
||||
// else add in a new profiler to the appropriate parent profiler
|
||||
DVPROFSTRUCT* pprof = NULL;
|
||||
|
||||
if (g_listCurTracking.size() > 0)
|
||||
{
|
||||
assert(g_listCurTracking.back().pprof != NULL);
|
||||
g_listCurTracking.back().pprof->listpChild.push_back(new DVPROFSTRUCT());
|
||||
pprof = g_listCurTracking.back().pprof->listpChild.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_listProfilers.push_back(DVPROFSTRUCT());
|
||||
pprof = &g_listProfilers.back();
|
||||
}
|
||||
|
||||
strncpy(pprof->pname, pname, 256);
|
||||
|
||||
// setup the profiler for tracking
|
||||
pprof->listTimes.push_back(DVPROFSTRUCT::DATA(GET_PROFILE_TIME()));
|
||||
|
||||
DVPROFTRACK dvtrack;
|
||||
dvtrack.pdwTime = &pprof->listTimes.back();
|
||||
dvtrack.pprof = pprof;
|
||||
dvtrack.dwUserData = 0;
|
||||
|
||||
g_listCurTracking.push_back(dvtrack);
|
||||
|
||||
// add to all profiler list
|
||||
g_listAllProfilers.push_back(pprof);
|
||||
}
|
||||
|
||||
void DVProfEnd(u32 dwUserData)
|
||||
{
|
||||
if (!g_bWriteProfile)
|
||||
return;
|
||||
|
||||
B_RETURN(g_listCurTracking.size() > 0);
|
||||
|
||||
DVPROFTRACK dvtrack = g_listCurTracking.back();
|
||||
|
||||
assert(dvtrack.pdwTime != NULL && dvtrack.pprof != NULL);
|
||||
|
||||
dvtrack.pdwTime->dwTime = 1000000 * (GET_PROFILE_TIME() - dvtrack.pdwTime->dwTime) / luPerfFreq;
|
||||
|
||||
dvtrack.pdwTime->dwUserData = dwUserData;
|
||||
|
||||
g_listCurTracking.pop_back();
|
||||
}
|
||||
|
||||
struct DVTIMEINFO
|
||||
{
|
||||
DVTIMEINFO() : uInclusive(0), uExclusive(0) {}
|
||||
|
||||
u64 uInclusive, uExclusive;
|
||||
};
|
||||
|
||||
map<string, DVTIMEINFO> mapAggregateTimes;
|
||||
|
||||
u64 DVProfWriteStruct(FILE* f, DVPROFSTRUCT* p, int ident)
|
||||
{
|
||||
fprintf(f, "%*s%s - ", ident, "", p->pname);
|
||||
|
||||
list<DVPROFSTRUCT::DATA>::iterator ittime = p->listTimes.begin();
|
||||
|
||||
u32 utime = 0;
|
||||
|
||||
while (ittime != p->listTimes.end())
|
||||
{
|
||||
utime += (u32)ittime->dwTime;
|
||||
|
||||
if (ittime->dwUserData)
|
||||
fprintf(f, "time: %d, user: 0x%8.8x", (u32)ittime->dwTime, ittime->dwUserData);
|
||||
else
|
||||
fprintf(f, "time: %d", (u32)ittime->dwTime);
|
||||
|
||||
++ittime;
|
||||
}
|
||||
|
||||
mapAggregateTimes[p->pname].uInclusive += utime;
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
list<DVPROFSTRUCT*>::iterator itprof = p->listpChild.begin();
|
||||
|
||||
u32 uex = utime;
|
||||
|
||||
while (itprof != p->listpChild.end())
|
||||
{
|
||||
|
||||
uex -= DVProfWriteStruct(f, *itprof, ident + 4);
|
||||
++itprof;
|
||||
}
|
||||
|
||||
mapAggregateTimes[p->pname].uExclusive += uex;
|
||||
|
||||
return utime;
|
||||
}
|
||||
|
||||
void DVProfWrite(char* pfilename, u32 frames)
|
||||
{
|
||||
assert(pfilename != NULL);
|
||||
FILE* f = fopen(pfilename, "wb");
|
||||
|
||||
mapAggregateTimes.clear();
|
||||
list<DVPROFSTRUCT>::iterator it = g_listProfilers.begin();
|
||||
|
||||
while (it != g_listProfilers.end())
|
||||
{
|
||||
DVProfWriteStruct(f, &(*it), 0);
|
||||
++it;
|
||||
}
|
||||
|
||||
{
|
||||
map<string, DVTIMEINFO>::iterator it;
|
||||
fprintf(f, "\n\n-------------------------------------------------------------------\n\n");
|
||||
|
||||
u64 uTotal[2] = {0};
|
||||
double fiTotalTime[2];
|
||||
|
||||
for (it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it)
|
||||
{
|
||||
uTotal[0] += it->second.uExclusive;
|
||||
uTotal[1] += it->second.uInclusive;
|
||||
}
|
||||
|
||||
fprintf(f, "total times (%d): ex: %Lu ", frames, uTotal[0] / frames);
|
||||
|
||||
fprintf(f, "inc: %Lu\n", uTotal[1] / frames);
|
||||
|
||||
fiTotalTime[0] = 1.0 / (double)uTotal[0];
|
||||
fiTotalTime[1] = 1.0 / (double)uTotal[1];
|
||||
|
||||
// output the combined times
|
||||
|
||||
for (it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it)
|
||||
{
|
||||
fprintf(f, "%s - ex: %f inc: %f\n", it->first.c_str(), (double)it->second.uExclusive * fiTotalTime[0],
|
||||
(double)it->second.uInclusive * fiTotalTime[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void DVProfClear()
|
||||
{
|
||||
g_listCurTracking.clear();
|
||||
g_listProfilers.clear();
|
||||
g_listAllProfilers.clear();
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/* ZeroGS KOSMOS
|
||||
* Copyright (C) 2005-2006 zerofrog@gmail.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PROFILE_H_INCLUDED
|
||||
#define PROFILE_H_INCLUDED
|
||||
|
||||
#include "zerogs.h"
|
||||
|
||||
#if !defined(ZEROGS_DEVBUILD)
|
||||
#define g_bWriteProfile 0
|
||||
#else
|
||||
extern bool g_bWriteProfile;
|
||||
#endif
|
||||
|
||||
extern u64 luPerfFreq;
|
||||
|
||||
|
||||
// Copied from Utilities; remove later.
|
||||
#ifdef __LINUX__
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
static __forceinline void InitCPUTicks()
|
||||
{
|
||||
}
|
||||
|
||||
static __forceinline u64 GetTickFrequency()
|
||||
{
|
||||
return 1000000; // unix measures in microseconds
|
||||
}
|
||||
|
||||
static __forceinline u64 GetCPUTicks()
|
||||
{
|
||||
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
return ((u64)t.tv_sec*GetTickFrequency()) + t.tv_usec;
|
||||
}
|
||||
|
||||
#else
|
||||
static __aligned16 LARGE_INTEGER lfreq;
|
||||
|
||||
static __forceinline void InitCPUTicks()
|
||||
{
|
||||
QueryPerformanceFrequency(&lfreq);
|
||||
}
|
||||
|
||||
static __forceinline u64 GetTickFrequency()
|
||||
{
|
||||
return lfreq.QuadPart;
|
||||
}
|
||||
|
||||
static __forceinline u64 GetCPUTicks()
|
||||
{
|
||||
LARGE_INTEGER count;
|
||||
QueryPerformanceCounter(&count);
|
||||
return count.QuadPart;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// IMPORTANT: For every Register there must be an End
|
||||
void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
|
||||
void DVProfEnd(u32 dwUserData);
|
||||
void DVProfWrite(char* pfilename, u32 frames = 0);
|
||||
void DVProfClear(); // clears all the profilers
|
||||
|
||||
#define DVPROFILE
|
||||
#ifdef DVPROFILE
|
||||
|
||||
class DVProfileFunc
|
||||
{
|
||||
public:
|
||||
u32 dwUserData;
|
||||
DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
|
||||
DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
|
||||
~DVProfileFunc() { DVProfEnd(dwUserData); }
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class DVProfileFunc
|
||||
{
|
||||
|
||||
public:
|
||||
u32 dwUserData;
|
||||
static __forceinline DVProfileFunc(char* pname) {}
|
||||
static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
|
||||
~DVProfileFunc() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template <typename T>
|
||||
class CInterfacePtr
|
||||
{
|
||||
|
||||
public:
|
||||
inline CInterfacePtr() : ptr(NULL) {}
|
||||
inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if (ptr != NULL) ptr->AddRef(); }
|
||||
inline ~CInterfacePtr() { if (ptr != NULL) ptr->Release(); }
|
||||
inline T* operator*() { assert(ptr != NULL); return *ptr; }
|
||||
inline T* operator->() { return ptr; }
|
||||
inline T* get() { return ptr; }
|
||||
|
||||
inline void release()
|
||||
{
|
||||
if (ptr != NULL) { ptr->Release(); ptr = NULL; }
|
||||
}
|
||||
|
||||
inline operator T*() { return ptr; }
|
||||
inline bool operator==(T* rhs) { return ptr == rhs; }
|
||||
inline bool operator!=(T* rhs) { return ptr != rhs; }
|
||||
|
||||
inline CInterfacePtr& operator= (T* newptr)
|
||||
{
|
||||
if (ptr != NULL) ptr->Release();
|
||||
|
||||
ptr = newptr;
|
||||
|
||||
if (ptr != NULL) ptr->AddRef();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
T* ptr;
|
||||
};
|
||||
|
||||
#endif // PROFILE_H_INCLUDED
|
|
@ -135,19 +135,22 @@ typedef struct
|
|||
int x, y, c;
|
||||
} PointC;
|
||||
|
||||
#define GSOPTION_FULLSCREEN 0x2
|
||||
#define GSOPTION_TGASNAP 0x4
|
||||
#define GSOPTION_CAPTUREAVI 0x8
|
||||
enum GSOption
|
||||
{
|
||||
GSOPTION_FULLSCREEN = 0x2,
|
||||
GSOPTION_TGASNAP = 0x4,
|
||||
GSOPTION_CAPTUREAVI = 0x8,
|
||||
|
||||
#define GSOPTION_WINDIMS 0x30
|
||||
#define GSOPTION_WIN640 0x00
|
||||
#define GSOPTION_WIN800 0x10
|
||||
#define GSOPTION_WIN1024 0x20
|
||||
#define GSOPTION_WIN1280 0x30
|
||||
#define GSOPTION_WIDESCREEN 0x40
|
||||
GSOPTION_WINDIMS = 0x30,
|
||||
GSOPTION_WIN640 = 0x00,
|
||||
GSOPTION_WIN800 = 0x10,
|
||||
GSOPTION_WIN1024 = 0x20,
|
||||
GSOPTION_WIN1280 = 0x30,
|
||||
GSOPTION_WIDESCREEN = 0x40,
|
||||
|
||||
#define GSOPTION_WIREFRAME 0x100
|
||||
#define GSOPTION_LOADED 0x8000
|
||||
GSOPTION_WIREFRAME = 0x100,
|
||||
GSOPTION_LOADED = 0x8000
|
||||
};
|
||||
|
||||
//Configuration values.
|
||||
|
||||
|
@ -300,118 +303,4 @@ extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
|
|||
extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
|
||||
#endif
|
||||
|
||||
// Copied from Utilities; remove later.
|
||||
#ifdef __LINUX__
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
static __forceinline void InitCPUTicks()
|
||||
{
|
||||
}
|
||||
|
||||
static __forceinline u64 GetTickFrequency()
|
||||
{
|
||||
return 1000000; // unix measures in microseconds
|
||||
}
|
||||
|
||||
static __forceinline u64 GetCPUTicks()
|
||||
{
|
||||
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
return ((u64)t.tv_sec*GetTickFrequency()) + t.tv_usec;
|
||||
}
|
||||
|
||||
#else
|
||||
static __aligned16 LARGE_INTEGER lfreq;
|
||||
|
||||
static __forceinline void InitCPUTicks()
|
||||
{
|
||||
QueryPerformanceFrequency(&lfreq);
|
||||
}
|
||||
|
||||
static __forceinline u64 GetTickFrequency()
|
||||
{
|
||||
return lfreq.QuadPart;
|
||||
}
|
||||
|
||||
static __forceinline u64 GetCPUTicks()
|
||||
{
|
||||
LARGE_INTEGER count;
|
||||
QueryPerformanceCounter(&count);
|
||||
return count.QuadPart;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
|
||||
class CInterfacePtr
|
||||
{
|
||||
|
||||
public:
|
||||
inline CInterfacePtr() : ptr(NULL) {}
|
||||
inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if (ptr != NULL) ptr->AddRef(); }
|
||||
inline ~CInterfacePtr() { if (ptr != NULL) ptr->Release(); }
|
||||
inline T* operator*() { assert(ptr != NULL); return *ptr; }
|
||||
inline T* operator->() { return ptr; }
|
||||
inline T* get() { return ptr; }
|
||||
|
||||
inline void release()
|
||||
{
|
||||
if (ptr != NULL) { ptr->Release(); ptr = NULL; }
|
||||
}
|
||||
|
||||
inline operator T*() { return ptr; }
|
||||
inline bool operator==(T* rhs) { return ptr == rhs; }
|
||||
inline bool operator!=(T* rhs) { return ptr != rhs; }
|
||||
|
||||
inline CInterfacePtr& operator= (T* newptr)
|
||||
{
|
||||
if (ptr != NULL) ptr->Release();
|
||||
|
||||
ptr = newptr;
|
||||
|
||||
if (ptr != NULL) ptr->AddRef();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
T* ptr;
|
||||
};
|
||||
|
||||
|
||||
// IMPORTANT: For every Register there must be an End
|
||||
void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
|
||||
void DVProfEnd(u32 dwUserData);
|
||||
void DVProfWrite(char* pfilename, u32 frames = 0);
|
||||
void DVProfClear(); // clears all the profilers
|
||||
|
||||
#define DVPROFILE
|
||||
#ifdef DVPROFILE
|
||||
|
||||
class DVProfileFunc
|
||||
{
|
||||
public:
|
||||
u32 dwUserData;
|
||||
DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
|
||||
DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
|
||||
~DVProfileFunc() { DVProfEnd(dwUserData); }
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class DVProfileFunc
|
||||
{
|
||||
|
||||
public:
|
||||
u32 dwUserData;
|
||||
static __forceinline DVProfileFunc(char* pname) {}
|
||||
static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
|
||||
~DVProfileFunc() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // UTIL_H_INCLUDED
|
||||
|
|
|
@ -21,6 +21,10 @@ void SaveConfig()
|
|||
WritePrivateProfileString("Settings", "Options", szValue, iniFile.c_str());
|
||||
sprintf(szValue, "%u", conf.gamesettings);
|
||||
WritePrivateProfileString("Settings", "AdvancedOptions", szValue, iniFile.c_str());
|
||||
sprintf(szValue, "%u", conf.width);
|
||||
WritePrivateProfileString("Settings", "Width", szValue, iniFile.c_str());
|
||||
sprintf(szValue, "%u", conf.height);
|
||||
WritePrivateProfileString("Settings", "Height", szValue, iniFile.c_str());
|
||||
}
|
||||
|
||||
void LoadConfig()
|
||||
|
@ -57,6 +61,10 @@ void LoadConfig()
|
|||
conf.gamesettings = strtoul(szValue, NULL, 10);
|
||||
GetPrivateProfileString("Settings", "Bilinear", NULL, szValue, 20, iniFile.c_str());
|
||||
conf.bilinear = strtoul(szValue, NULL, 10);
|
||||
GetPrivateProfileString("Settings", "Width", NULL, szValue, 20, iniFile.c_str());
|
||||
conf.width = strtoul(szValue, NULL, 10);
|
||||
GetPrivateProfileString("Settings", "Height", NULL, szValue, 20, iniFile.c_str());
|
||||
conf.height = strtoul(szValue, NULL, 10);
|
||||
|
||||
if (conf.aa < 0 || conf.aa > 4) conf.aa = 0;
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@
|
|||
<ClCompile Include="..\memcpy_amd.cpp" />
|
||||
<ClCompile Include="..\rasterfont.cpp" />
|
||||
<ClCompile Include="..\Regs.cpp" />
|
||||
<ClCompile Include="..\Profile.cpp" />
|
||||
<ClCompile Include="..\targets.cpp" />
|
||||
<ClCompile Include="Win32.cpp" />
|
||||
<ClCompile Include="..\x86.cpp" />
|
||||
|
@ -191,6 +192,7 @@
|
|||
<ClInclude Include="..\PS2Etypes.h" />
|
||||
<ClInclude Include="..\rasterfont.h" />
|
||||
<ClInclude Include="..\Regs.h" />
|
||||
<ClInclude Include="..\Profile.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="resrc1.h" />
|
||||
<ClInclude Include="..\targets.h" />
|
||||
|
|
|
@ -297,6 +297,10 @@
|
|||
RelativePath="..\Regs.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Profile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\targets.cpp"
|
||||
>
|
||||
|
@ -425,6 +429,10 @@
|
|||
RelativePath="..\Regs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Profile.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="resource.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue