mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,38 +250,35 @@ 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;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
// 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]));
|
||||
}
|
||||
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));
|
||||
|
||||
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]));
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
#if defined(DVPROFILE) && (defined(_WIN32)||defined(WIN32))
|
||||
void DVProfWrite(const char* pfilename, u32 frames = 0);
|
||||
void DVProfGenReport(std::string *report);
|
||||
void DVProfClear(); // clears all the profilers
|
||||
|
||||
#if defined(DVPROFILE) && defined(_WIN32)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
|
||||
@@ -490,6 +490,14 @@
|
||||
AssemblerOutput="4"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AssemblerOutput="4"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XFBConvert.h"
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _GLOBALS_H
|
||||
#define _GLOBALS_H
|
||||
|
||||
|
||||
|
||||
#include "Common.h"
|
||||
#include "pluginspecs_dsp.h"
|
||||
|
||||
@@ -14,6 +29,4 @@ u16 Memory_Read_U16(u32 _uAddress);
|
||||
u32 Memory_Read_U32(u32 _uAddress);
|
||||
float Memory_Read_Float(u32 _uAddress);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -763,6 +763,22 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Docs"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\Docs\DSP\Crazy Taxi.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\Docs\DSP\dsp_rom.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\Docs\DSP\DSP_UC_Zelda.txt"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Src\DSoundStream.cpp"
|
||||
>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "Profiler.h"
|
||||
#include "BPStructs.h"
|
||||
#include "OpcodeDecoding.h"
|
||||
#include "TextureCache.h"
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "BPMemory.h"
|
||||
|
||||
void BPInit();
|
||||
//bool BPWritten(int addr, int changes);
|
||||
void LoadBPReg(u32 value0);
|
||||
void ActivateTextures();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "D3DBase.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Profiler.h"
|
||||
#include "Globals.h"
|
||||
#include "VertexHandler.h"
|
||||
#include "TransformEngine.h"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "Utils.h"
|
||||
#include "Profiler.h"
|
||||
#include "Globals.h"
|
||||
#include "ShaderManager.h"
|
||||
#include "VertexLoader.h"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <fvec.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Profiler.h"
|
||||
#include "Globals.h"
|
||||
#include "Vec3.h"
|
||||
#include "TransformEngine.h"
|
||||
|
||||
@@ -43,274 +43,3 @@ LRESULT CALLBACK AboutProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lPar
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
////////////////////
|
||||
// Small profiler //
|
||||
////////////////////
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
int g_bWriteProfile=0;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined (_MSC_VER) && _MSC_VER >= 1400
|
||||
#define _interlockedbittestandset workaround_ms_header_bug_platform_sdk6_set
|
||||
#define _interlockedbittestandreset workaround_ms_header_bug_platform_sdk6_reset
|
||||
#define _interlockedbittestandset64 workaround_ms_header_bug_platform_sdk6_set64
|
||||
#define _interlockedbittestandreset64 workaround_ms_header_bug_platform_sdk6_reset64
|
||||
#include <intrin.h>
|
||||
#undef _interlockedbittestandset
|
||||
#undef _interlockedbittestandreset
|
||||
#undef _interlockedbittestandset64
|
||||
#undef _interlockedbittestandreset64
|
||||
#pragma intrinsic(__rdtsc)
|
||||
#endif
|
||||
|
||||
static u64 luPerfFreq=0;
|
||||
inline u64 GET_PROFILE_TIME()
|
||||
{
|
||||
#if defined (_MSC_VER) && _MSC_VER >= 1400
|
||||
return __rdtsc();
|
||||
#else
|
||||
LARGE_INTEGER lu;
|
||||
QueryPerformanceCounter(&lu);
|
||||
return lu.QuadPart;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
static u64 luPerfFreq = 1000000;
|
||||
#define GET_PROFILE_TIME() //GetCpuTick()
|
||||
#endif
|
||||
|
||||
|
||||
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() ) {
|
||||
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
|
||||
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;
|
||||
|
||||
#ifdef _WIN32
|
||||
if( luPerfFreq <= 1 ) {
|
||||
#if defined (_MSC_VER) && _MSC_VER >= 1400
|
||||
luPerfFreq = 1000000;
|
||||
#else
|
||||
LARGE_INTEGER temp;
|
||||
QueryPerformanceFrequency(&temp);
|
||||
luPerfFreq = temp.QuadPart;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
if( g_listCurTracking.size() == 0 )
|
||||
return;
|
||||
|
||||
DVPROFTRACK dvtrack = g_listCurTracking.back();
|
||||
|
||||
assert( dvtrack.pdwTime != NULL && dvtrack.pprof != NULL );
|
||||
|
||||
dvtrack.pdwTime->dwTime = GET_PROFILE_TIME()- dvtrack.pdwTime->dwTime;
|
||||
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();
|
||||
|
||||
u64 utime = 0;
|
||||
|
||||
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
|
||||
fprintf(f, "time: %d", (u32)ittime->dwTime);
|
||||
++ittime;
|
||||
}
|
||||
|
||||
// yes this is necessary, maps have problems with constructors on their type
|
||||
map<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->second.uExclusive = 0;
|
||||
ittimes->second.uInclusive = 0;
|
||||
}
|
||||
|
||||
ittimes->second.uInclusive += utime;
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
list<DVPROFSTRUCT*>::iterator itprof = p->listpChild.begin();
|
||||
|
||||
u64 uex = utime;
|
||||
while(itprof != p->listpChild.end() ) {
|
||||
|
||||
uex -= DVProfWriteStruct(f, *itprof, ident+4);
|
||||
++itprof;
|
||||
}
|
||||
|
||||
if( uex > utime ) {
|
||||
uex = 0;
|
||||
}
|
||||
|
||||
ittimes->second.uExclusive += uex;
|
||||
return utime;
|
||||
}
|
||||
|
||||
void DVProfWrite(char* pfilename, u32 frames)
|
||||
{
|
||||
assert( pfilename != NULL );
|
||||
FILE* f = fopen(pfilename, "w");
|
||||
|
||||
// pop back any unused
|
||||
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, 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];
|
||||
|
||||
// output the combined times
|
||||
for(it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it) {
|
||||
fprintf(f, "%s - ex: %f inc: %f\n", it->first.c_str(), (float)((double)it->second.uExclusive * fiTotalTime[0]),
|
||||
(float)((double)it->second.uInclusive * fiTotalTime[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void DVProfClear()
|
||||
{
|
||||
g_listCurTracking.clear();
|
||||
g_listProfilers.clear();
|
||||
g_listAllProfilers.clear();
|
||||
}
|
||||
|
||||
@@ -60,54 +60,4 @@ inline float Memory_Read_Float(u32 _uAddress)
|
||||
return *(float*)&uTemp;
|
||||
}
|
||||
|
||||
////
|
||||
// profiling
|
||||
///
|
||||
|
||||
extern int g_bWriteProfile; // global variable to enable/disable profiling (if DVPROFILE is defined)
|
||||
|
||||
// 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 // comment out to disable profiling
|
||||
|
||||
#if defined(DVPROFILE) && (defined(_WIN32)||defined(WIN32))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#ifndef __PRETTY_FUNCTION__
|
||||
#define __PRETTY_FUNCTION__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define DVSTARTPROFILE() DVProfileFunc _pf(__PRETTY_FUNCTION__);
|
||||
|
||||
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
|
||||
|
||||
#define DVSTARTPROFILE()
|
||||
|
||||
class DVProfileFunc
|
||||
{
|
||||
public:
|
||||
u32 dwUserData;
|
||||
__forceinline DVProfileFunc(char* pname) {}
|
||||
__forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
|
||||
~DVProfileFunc() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "D3DBase.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Profiler.h"
|
||||
#include "Globals.h"
|
||||
#include "VertexHandler.h"
|
||||
#include "OpcodeDecoding.h"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "x64Emitter.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Profiler.h"
|
||||
#include "VertexHandler.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "XFStructs.h"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Profiler.h"
|
||||
#include "XFStructs.h"
|
||||
#include "Render.h"
|
||||
#include "main.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Version="9,00"
|
||||
Name="Plugin_VideoOGL"
|
||||
ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}"
|
||||
RootNamespace="Plugin_VideoOGL"
|
||||
@@ -760,6 +760,14 @@
|
||||
RelativePath=".\Src\VertexLoader_TextCoord.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\VertexManager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\VertexManager.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Render"
|
||||
@@ -1072,6 +1080,14 @@
|
||||
RelativePath=".\Src\Logging\Console.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\ImageWrite.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\ImageWrite.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Logging\Logging.cpp"
|
||||
>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user