summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2008-10-17 11:30:14 +0000
committerhrydgard <hrydgard@gmail.com>2008-10-17 11:30:14 +0000
commitdcbc8e78d47dabd3762d9c654df01ba57dfd8d4c (patch)
treec5fa39bf50e6471e848ac93ac0e173d8aa92530d /Source/Core
parent4477f77cf6c37e07433979331c22f362602ac76c (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')
-rw-r--r--Source/Core/Common/Src/Common.h12
-rw-r--r--Source/Core/DiscIO/Src/FileSystemGCWii.cpp9
-rw-r--r--Source/Core/VideoCommon/Src/DataReader.h10
-rw-r--r--Source/Core/VideoCommon/Src/Profiler.cpp124
-rw-r--r--Source/Core/VideoCommon/Src/Profiler.h12
-rw-r--r--Source/Core/VideoCommon/VideoCommon.vcproj8
6 files changed, 91 insertions, 84 deletions
diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h
index 1280b3dc30..1d38fcccaa 100644
--- a/Source/Core/Common/Src/Common.h
+++ b/Source/Core/Common/Src/Common.h
@@ -49,10 +49,12 @@
#endif
#ifdef _WIN32
-#ifdef _WIN32
+
+// By default, MS' stdio implementation does not support 64-bit offsets.
+// This little hack fixes that, keeping the code portable to linux where fseek and fread
+// do support 64-bit offsets in modern distributions.
#define fseek _fseeki64
#define ftell _ftelli64
-#endif
#define POSIX 0
#define NOMINMAX
@@ -128,11 +130,9 @@ typedef union _LARGE_INTEGER
#undef max
template<class T>
-inline T min(const T& a, const T& b) {return(a > b ? b : a);}
-
-
+inline T min(const T& a, const T& b) {return a > b ? b : a;}
template<class T>
-inline T max(const T& a, const T& b) {return(a > b ? a : b);}
+inline T max(const T& a, const T& b) {return a > b ? a : b;}
// Byte ordering
diff --git a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp
index bd9eb34dd3..a06b55836e 100644
--- a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp
+++ b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp
@@ -158,11 +158,11 @@ bool CFileSystemGCWii::InitFileSystem()
{
if (Read32(0x18) == 0x5D1C9EA3)
{
- m_OffsetShift = 2;
+ m_OffsetShift = 2; // Wii file system
}
else if (Read32(0x1c) == 0xC2339F3D)
{
- m_OffsetShift = 0;
+ m_OffsetShift = 0; // GC file system
}
else
{
@@ -206,8 +206,6 @@ bool CFileSystemGCWii::InitFileSystem()
return true;
}
-// __________________________________________________________________________________________________
-//
// Changed this stuff from C++ string to C strings for speed in debug mode. Doesn't matter in release, but
// std::string is SLOW in debug mode.
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset)
@@ -248,5 +246,4 @@ size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _
return CurrentIndex;
}
-} // namespace
-
+} // namespace
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"