diff options
| author | hrydgard <hrydgard@gmail.com> | 2008-10-17 11:30:14 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2008-10-17 11:30:14 +0000 |
| commit | dcbc8e78d47dabd3762d9c654df01ba57dfd8d4c (patch) | |
| tree | c5fa39bf50e6471e848ac93ac0e173d8aa92530d /Source/Core/VideoCommon | |
| parent | 4477f77cf6c37e07433979331c22f362602ac76c (diff) | |
Massive style & comment cleanup of (mostly) GL plugin - also split some large files. A minor speedup for BP writes - merged the two switch()-es.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@899 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/DataReader.h | 10 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/Profiler.cpp | 124 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/Profiler.h | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoCommon.vcproj | 8 |
4 files changed, 82 insertions, 72 deletions
diff --git a/Source/Core/VideoCommon/Src/DataReader.h b/Source/Core/VideoCommon/Src/DataReader.h index 09623a5c69..3f465a46e5 100644 --- a/Source/Core/VideoCommon/Src/DataReader.h +++ b/Source/Core/VideoCommon/Src/DataReader.h @@ -18,11 +18,8 @@ #ifndef _DATAREADER_H
#define _DATAREADER_H
-
extern u8* g_pVideoData;
-
-
inline u8 DataPeek8(u32 _uOffset)
{
return g_pVideoData[_uOffset];
@@ -46,14 +43,14 @@ inline u8 DataReadU8() inline u16 DataReadU16()
{
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
- g_pVideoData+=2;
+ g_pVideoData += 2;
return tmp;
}
inline u32 DataReadU32()
{
u32 tmp = Common::swap32(*(u32*)g_pVideoData);
- g_pVideoData+=4;
+ g_pVideoData += 4;
return tmp;
}
@@ -61,7 +58,7 @@ inline float DataReadF32() {
union {u32 i; float f;} temp;
temp.i = Common::swap32(*(u32*)g_pVideoData);
- g_pVideoData+=4;
+ g_pVideoData += 4;
float tmp = temp.f;
return tmp;
}
@@ -77,4 +74,3 @@ inline void DataSkip(u32 skip) }
#endif
-
diff --git a/Source/Core/VideoCommon/Src/Profiler.cpp b/Source/Core/VideoCommon/Src/Profiler.cpp index 9c7a543c77..b66a4d32d2 100644 --- a/Source/Core/VideoCommon/Src/Profiler.cpp +++ b/Source/Core/VideoCommon/Src/Profiler.cpp @@ -15,20 +15,14 @@ // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#include "Common.h"
+// Simple profiler
+#include "Common.h"
#include "Profiler.h"
-
-////////////////////
-// Small profiler //
-////////////////////
#include <list>
#include <string>
#include <map>
-using namespace std;
-
-int g_bWriteProfile=0;
#ifdef _WIN32
@@ -45,7 +39,14 @@ int g_bWriteProfile=0; #pragma intrinsic(__rdtsc)
#endif
-static u64 luPerfFreq=0;
+// Globals
+static u64 luPerfFreq = 0;
+#ifdef DVPROFILE
+int g_bWriteProfile = 1;
+#else
+int g_bWriteProfile = 1;
+#endif
+
inline u64 GET_PROFILE_TIME()
{
#if defined (_MSC_VER) && _MSC_VER >= 1400
@@ -57,11 +58,10 @@ inline u64 GET_PROFILE_TIME() #endif
}
#else
-static u64 luPerfFreq=1000000;
+static u64 luPerfFreq = 1000000;
#define GET_PROFILE_TIME() //GetCpuTick()
#endif
-
struct DVPROFSTRUCT;
struct DVPROFSTRUCT
@@ -70,25 +70,27 @@ struct DVPROFSTRUCT {
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() ) {
- delete *it; *it = NULL;
+ std::list<DVPROFSTRUCT *>::iterator it = listpChild.begin();
+ while (it != listpChild.end()) {
+ delete *it;
+ *it = NULL;
++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
+ // 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
+ std::list<DATA> listTimes;
+
char pname[256];
-
- list<DVPROFSTRUCT*> listpChild; // other profilers called during this profiler period
+ std::list<DVPROFSTRUCT*> listpChild; // other profilers called during this profiler period
};
struct DVPROFTRACK
@@ -98,13 +100,19 @@ struct DVPROFTRACK 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
+// 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
+static std::list<DVPROFTRACK> g_listCurTracking;
+
+// the current profilers, note that these are the parents
+// any profiler started during the time of another is held in
+// DVPROFSTRUCT::listpChild
+static std::list<DVPROFSTRUCT> g_listProfilers;
+
+// ignores the hierarchy, pointer to elements in g_listProfilers
+static std::list<DVPROFSTRUCT*> g_listAllProfilers;
+
void DVProfRegister(const char *pname)
{
@@ -123,7 +131,7 @@ void DVProfRegister(const char *pname) }
#endif
- list<DVPROFSTRUCT*>::iterator it = g_listAllProfilers.begin();
+ std::list<DVPROFSTRUCT*>::iterator it = g_listAllProfilers.begin();
// while(it != g_listAllProfilers.end() ) {
//
@@ -191,19 +199,15 @@ struct DVTIMEINFO u64 uInclusive, uExclusive;
};
-map<string, DVTIMEINFO> mapAggregateTimes;
+std::map<std::string, DVTIMEINFO> mapAggregateTimes;
-u64 DVProfWriteStruct(FILE* f, DVPROFSTRUCT* p, int ident)
+u64 DVProfWriteStruct(FILE* f, const DVPROFSTRUCT* p, int ident)
{
fprintf(f, "%*s%s - ", ident, "", p->pname);
-
- list<DVPROFSTRUCT::DATA>::iterator ittime = p->listTimes.begin();
-
+ std::list<DVPROFSTRUCT::DATA>::const_iterator ittime = p->listTimes.begin();
u64 utime = 0;
-
- while(ittime != p->listTimes.end() ) {
+ while (ittime != p->listTimes.end()) {
utime += ittime->dwTime;
-
if (ittime->dwUserData)
fprintf(f, "time: %d, user: 0x%8.8x", (u32)ittime->dwTime, ittime->dwUserData);
else
@@ -212,9 +216,9 @@ u64 DVProfWriteStruct(FILE* f, DVPROFSTRUCT* p, int ident) }
// yes this is necessary, maps have problems with constructors on their type
- map<string, DVTIMEINFO>::iterator ittimes = mapAggregateTimes.find(p->pname);
+ std::map<std::string, DVTIMEINFO>::iterator ittimes = mapAggregateTimes.find(p->pname);
if (ittimes == mapAggregateTimes.end()) {
- ittimes = mapAggregateTimes.insert(map<string, DVTIMEINFO>::value_type(p->pname, DVTIMEINFO())).first;
+ ittimes = mapAggregateTimes.insert(std::map<std::string, DVTIMEINFO>::value_type(p->pname, DVTIMEINFO())).first;
ittimes->second.uExclusive = 0;
ittimes->second.uInclusive = 0;
}
@@ -223,11 +227,10 @@ u64 DVProfWriteStruct(FILE* f, DVPROFSTRUCT* p, int ident) fprintf(f, "\n");
- list<DVPROFSTRUCT*>::iterator itprof = p->listpChild.begin();
+ std::list<DVPROFSTRUCT*>::const_iterator itprof = p->listpChild.begin();
u64 uex = utime;
- while(itprof != p->listpChild.end() ) {
-
+ while (itprof != p->listpChild.end()) {
uex -= DVProfWriteStruct(f, *itprof, ident+4);
++itprof;
}
@@ -247,39 +250,36 @@ void DVProfWrite(const char* pfilename, u32 frames) // pop back any unused
mapAggregateTimes.clear();
- list<DVPROFSTRUCT>::iterator it = g_listProfilers.begin();
+ std::list<DVPROFSTRUCT>::iterator it = g_listProfilers.begin();
- while(it != g_listProfilers.end() ) {
+ while (it != g_listProfilers.end() ) {
DVProfWriteStruct(f, &(*it), 0);
++it;
}
- {
- map<string, DVTIMEINFO>::iterator iter;
- fprintf(f, "\n\n-------------------------------------------------------------------\n\n");
+ std::map<std::string, DVTIMEINFO>::const_iterator iter;
+ fprintf(f, "\n\n-------------------------------------------------------------------\n\n");
- u64 uTotal[2] = {0};
- double fiTotalTime[2];
+ u64 uTotal[2] = {0};
+ double fiTotalTime[2];
- for(iter = mapAggregateTimes.begin(); iter != mapAggregateTimes.end(); ++iter) {
- uTotal[0] += iter->second.uExclusive;
- uTotal[1] += iter->second.uInclusive;
- }
+ for (iter = mapAggregateTimes.begin(); iter != mapAggregateTimes.end(); ++iter) {
+ uTotal[0] += iter->second.uExclusive;
+ uTotal[1] += iter->second.uInclusive;
+ }
- fprintf(f, "total times (%d): ex: %Lu ", frames, 1000000*uTotal[0]/(luPerfFreq*(u64)frames));
- fprintf(f, "inc: %Lu\n", 1000000 * uTotal[1]/(luPerfFreq*(u64)frames));
+ fprintf(f, "total times (%d): ex: %Lu ", frames, 1000000 * uTotal[0] / (luPerfFreq*(u64)frames));
+ fprintf(f, "inc: %Lu\n", 1000000 * uTotal[1]/(luPerfFreq*(u64)frames));
- fiTotalTime[0] = 1.0 / (double)uTotal[0];
- fiTotalTime[1] = 1.0 / (double)uTotal[1];
+ fiTotalTime[0] = 1.0 / (double)uTotal[0];
+ fiTotalTime[1] = 1.0 / (double)uTotal[1];
- // output the combined times
- for(iter = mapAggregateTimes.begin(); iter != mapAggregateTimes.end(); ++iter) {
- fprintf(f, "%s - ex: %f inc: %f\n", iter->first.c_str(), (float)((double)iter->second.uExclusive * fiTotalTime[0]),
- (float)((double)iter->second.uInclusive * fiTotalTime[1]));
- }
+ // output the combined times
+ for (iter = mapAggregateTimes.begin(); iter != mapAggregateTimes.end(); ++iter) {
+ fprintf(f, "%s - ex: %f inc: %f\n", iter->first.c_str(), (float)((double)iter->second.uExclusive * fiTotalTime[0]),
+ (float)((double)iter->second.uInclusive * fiTotalTime[1]));
}
-
fclose(f);
}
diff --git a/Source/Core/VideoCommon/Src/Profiler.h b/Source/Core/VideoCommon/Src/Profiler.h index 561ee7aa13..5cc8d55cd1 100644 --- a/Source/Core/VideoCommon/Src/Profiler.h +++ b/Source/Core/VideoCommon/Src/Profiler.h @@ -21,17 +21,23 @@ #ifndef _PROFILER_H
#define _PROFILER_H
+#include <string>
+
+#include "Common.h"
+
// #define DVPROFILE // comment out to disable profiling
extern int g_bWriteProfile; // global variable to enable/disable profiling (if DVPROFILE is defined)
-// IMPORTANT: For every Register there must be an End
+// IMPORTANT: For every Register there must be an End. Use the below DVProfileFunc utility class for safety.
void DVProfRegister(const char* pname); // first checks if this profiler exists in g_listProfilers
void DVProfEnd(u32 dwUserData);
+
void DVProfWrite(const char* pfilename, u32 frames = 0);
-void DVProfClear(); // clears all the profi lers
+void DVProfGenReport(std::string *report);
+void DVProfClear(); // clears all the profilers
-#if defined(DVPROFILE) && (defined(_WIN32)||defined(WIN32))
+#if defined(DVPROFILE) && defined(_WIN32)
#ifdef _MSC_VER
diff --git a/Source/Core/VideoCommon/VideoCommon.vcproj b/Source/Core/VideoCommon/VideoCommon.vcproj index bc489c85af..ce0a0a536c 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcproj +++ b/Source/Core/VideoCommon/VideoCommon.vcproj @@ -490,6 +490,14 @@ AssemblerOutput="4"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AssemblerOutput="4"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\Src\XFBConvert.h"
|
