Merge branch 'master' into windows-unicode

This commit is contained in:
Jordan Woyak
2013-03-02 15:33:32 -06:00
64 changed files with 1083 additions and 183 deletions

View File

@ -29,6 +29,7 @@
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <string>
@ -45,7 +46,8 @@ struct LinkedListItem : public T
class PointerWrap
{
public:
enum Mode {
enum Mode
{
MODE_READ = 1, // load
MODE_WRITE, // save
MODE_MEASURE, // calculate size
@ -57,124 +59,95 @@ public:
public:
PointerWrap(u8 **ptr_, Mode mode_) : ptr(ptr_), mode(mode_) {}
PointerWrap(unsigned char **ptr_, int mode_) : ptr((u8**)ptr_), mode((Mode)mode_) {}
void SetMode(Mode mode_) {mode = mode_;}
Mode GetMode() const {return mode;}
u8 **GetPPtr() {return ptr;}
void SetMode(Mode mode_) { mode = mode_; }
Mode GetMode() const { return mode; }
u8** GetPPtr() { return ptr; }
void DoVoid(void *data, int size)
template <typename K, class V>
void Do(std::map<K, V>& x)
{
switch (mode) {
case MODE_READ: memcpy(data, *ptr, size); break;
case MODE_WRITE: memcpy(*ptr, data, size); break;
case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break;
default: break; // throw an error?
}
(*ptr) += size;
}
template<class T>
void Do(std::map<unsigned int, T> &x)
{
unsigned int number = (unsigned int)x.size();
Do(number);
switch (mode) {
u32 count = (u32)x.size();
Do(count);
switch (mode)
{
case MODE_READ:
for (x.clear(); count != 0; --count)
{
x.clear();
while (number > 0)
{
unsigned int first = 0;
Do(first);
T second;
Do(second);
x[first] = second;
--number;
}
std::pair<K, V> pair;
Do(pair.first);
Do(pair.second);
x.insert(pair);
}
break;
case MODE_WRITE:
case MODE_MEASURE:
case MODE_VERIFY:
for (auto itr = x.begin(); itr != x.end(); ++itr)
{
typename std::map<unsigned int, T>::iterator itr = x.begin();
while (number > 0)
{
Do(itr->first);
Do(itr->second);
--number;
++itr;
}
Do(itr->first);
Do(itr->second);
}
break;
}
}
// Store vectors.
template<class T>
void Do(std::vector<T> &x)
{
u32 vec_size = (u32)x.size();
Do(vec_size);
x.resize(vec_size);
DoArray(&x[0], vec_size);
}
// Store deques.
template<class T>
void Do(std::deque<T> &x)
template <typename T>
void DoContainer(T& x)
{
u32 deq_size = (u32)x.size();
Do(deq_size);
x.resize(deq_size);
u32 i;
for(i = 0; i < deq_size; i++)
DoVoid(&x[i],sizeof(T));
}
// Store strings.
void Do(std::string &x)
{
int stringLen = (int)x.length() + 1;
Do(stringLen);
u32 size = (u32)x.size();
Do(size);
x.resize(size);
switch (mode) {
case MODE_READ: x = (char*)*ptr; break;
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
case MODE_MEASURE: break;
case MODE_VERIFY: _dbg_assert_msg_(COMMON, !strcmp(x.c_str(), (char*)*ptr), "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", x.c_str(), (char*)*ptr, ptr); break;
}
(*ptr) += stringLen;
for (auto itr = x.begin(); itr != x.end(); ++itr)
Do(*itr);
}
void Do(std::wstring &x)
template <typename T>
void Do(std::vector<T>& x)
{
int stringLen = sizeof(wchar_t)*((int)x.length() + 1);
Do(stringLen);
switch (mode) {
case MODE_READ: x.assign((wchar_t*)*ptr, (stringLen / sizeof(wchar_t)) - 1); break;
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
case MODE_MEASURE: break;
case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break;
}
(*ptr) += stringLen;
DoContainer(x);
}
template <typename T>
void Do(std::list<T>& x)
{
DoContainer(x);
}
template <typename T>
void Do(std::deque<T>& x)
{
DoContainer(x);
}
template <typename T>
void Do(std::basic_string<T>& x)
{
DoContainer(x);
}
template<class T>
void DoArray(T *x, int count) {
DoVoid((void *)x, sizeof(T) * count);
template <typename T>
void DoArray(T* x, u32 count)
{
for (u32 i = 0; i != count; ++i)
Do(x[i]);
}
template<class T>
void Do(T &x) {
DoVoid((void *)&x, sizeof(x));
template <typename T>
void Do(T& x)
{
// TODO: Bad, Do(some_non_POD) will compile and fail at runtime
// type_traits are not fully supported everywhere yet
DoVoid((void*)&x, sizeof(x));
}
template<class T>
void DoPointer(T* &x, T*const base) {
template <typename T>
void DoPointer(T*& x, T* const base)
{
// pointers can be more than 2^31 apart, but you're using this function wrong if you need that much range
s32 offset = x - base;
Do(offset);
@ -182,7 +155,8 @@ public:
x = base + offset;
}
template<class T, LinkedListItem<T>* (*TNew)(), void (*TFree)(LinkedListItem<T>*), void (*TDo)(PointerWrap&, T*)>
// Let's pretend std::list doesn't exist!
template <class T, LinkedListItem<T>* (*TNew)(), void (*TFree)(LinkedListItem<T>*), void (*TDo)(PointerWrap&, T*)>
void DoLinkedList(LinkedListItem<T>*& list_start, LinkedListItem<T>** list_end=0)
{
LinkedListItem<T>* list_cur = list_start;
@ -242,25 +216,61 @@ public:
}
}
void DoMarker(const char* prevName, u32 arbitraryNumber=0x42)
void DoMarker(const char* prevName, u32 arbitraryNumber = 0x42)
{
u32 cookie = arbitraryNumber;
Do(cookie);
if(mode == PointerWrap::MODE_READ && cookie != arbitraryNumber)
if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber)
{
PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...",
prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
mode = PointerWrap::MODE_MEASURE;
}
}
private:
__forceinline void DoByte(u8& x)
{
switch (mode)
{
case MODE_READ:
x = **ptr;
break;
case MODE_WRITE:
**ptr = x;
break;
case MODE_MEASURE:
break;
case MODE_VERIFY:
_dbg_assert_msg_(COMMON, (x == *ptr),
"Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n",
x, x, &x, *ptr, *ptr, &*ptr);
break;
default:
break;
}
++(*ptr);
}
void DoVoid(void *data, u32 size)
{
for(u32 i = 0; i != size; ++i)
DoByte(reinterpret_cast<u8*>(data)[i]);
}
};
class CChunkFileReader
{
public:
// Load file template
template<class T>
static bool Load(const std::string& _rFilename, int _Revision, T& _class)
static bool Load(const std::string& _rFilename, u32 _Revision, T& _class)
{
INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
@ -300,7 +310,7 @@ public:
}
// get size
const int sz = (int)(fileSize - headerSize);
const u32 sz = (u32)(fileSize - headerSize);
if (header.ExpectedSize != sz)
{
ERROR_LOG(COMMON,"ChunkReader: Bad file size, got %d expected %d",
@ -309,17 +319,16 @@ public:
}
// read the state
u8* buffer = new u8[sz];
if (!pFile.ReadBytes(buffer, sz))
std::vector<u8> buffer(sz);
if (!pFile.ReadArray(&buffer[0], sz))
{
ERROR_LOG(COMMON,"ChunkReader: Error reading file");
return false;
}
u8 *ptr = buffer;
u8* ptr = &buffer[0];
PointerWrap p(&ptr, PointerWrap::MODE_READ);
_class.DoState(p);
delete[] buffer;
INFO_LOG(COMMON, "ChunkReader: Done loading %s" , _rFilename.c_str());
return true;
@ -327,7 +336,7 @@ public:
// Save file template
template<class T>
static bool Save(const std::string& _rFilename, int _Revision, T& _class)
static bool Save(const std::string& _rFilename, u32 _Revision, T& _class)
{
INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());
File::IOFile pFile(_rFilename, "wb");
@ -349,9 +358,8 @@ public:
// Create header
SChunkHeader header;
header.Compress = 0;
header.Revision = _Revision;
header.ExpectedSize = (int)sz;
header.ExpectedSize = (u32)sz;
// Write to file
if (!pFile.WriteArray(&header, 1))
@ -360,23 +368,21 @@ public:
return false;
}
if (!pFile.WriteBytes(&buffer[0], sz))
if (!pFile.WriteArray(&buffer[0], sz))
{
ERROR_LOG(COMMON,"ChunkReader: Failed writing data");
return false;
}
INFO_LOG(COMMON,"ChunkReader: Done writing %s",
_rFilename.c_str());
INFO_LOG(COMMON,"ChunkReader: Done writing %s", _rFilename.c_str());
return true;
}
private:
struct SChunkHeader
{
int Revision;
int Compress;
int ExpectedSize;
u32 Revision;
u32 ExpectedSize;
};
};

View File

@ -249,7 +249,7 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
while(1)
{
const int pos = result.find(src);
if (pos == 16) break;
if (pos == -1) break;
result.replace(pos, src.size(), dest);
}
return result;

View File

@ -22,6 +22,7 @@
#include <vector>
#include "ChunkFile.h"
#include "../../VideoCommon/Src/PerfQueryBase.h"
typedef void (*writeFn16)(const u16,const u32);
typedef void (*writeFn32)(const u32,const u32);
@ -107,6 +108,7 @@ public:
virtual void Video_EndField() = 0;
virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0;
virtual u32 Video_GetQueryResult(PerfQueryType type) = 0;
virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0;
virtual void Video_ClearMessages() = 0;
@ -156,8 +158,10 @@ class VideoBackendHardware : public VideoBackend
void Video_ExitLoop();
void Video_BeginField(u32, FieldType, u32, u32);
void Video_EndField();
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
u32 Video_GetQueryResult(PerfQueryType type);
void Video_AddMessage(const char* pstr, unsigned int milliseconds);
void Video_ClearMessages();
bool Video_Screenshot(const char* filename);

View File

@ -362,7 +362,11 @@ void SConfig::LoadSettings()
// Core
ini.Get("Core", "HLE_BS2", &m_LocalCoreStartupParameter.bHLE_BS2, false);
#ifdef _M_ARM
ini.Get("Core", "CPUCore", &m_LocalCoreStartupParameter.iCPUCore, 3);
#else
ini.Get("Core", "CPUCore", &m_LocalCoreStartupParameter.iCPUCore, 1);
#endif
ini.Get("Core", "DSPThread", &m_LocalCoreStartupParameter.bDSPThread, false);
ini.Get("Core", "DSPHLE", &m_LocalCoreStartupParameter.bDSPHLE, true);
ini.Get("Core", "CPUThread", &m_LocalCoreStartupParameter.bCPUThread, true);

View File

@ -133,7 +133,7 @@ unsigned int GetAttached()
// input/output: ptr
// input: mode
//
void DoState(unsigned char **ptr, int mode)
void DoState(u8 **ptr, PointerWrap::Mode mode)
{
// TODO:

View File

@ -3,6 +3,7 @@
#define _WIIMOTE_H_
#include "../../InputCommon/Src/InputConfig.h"
#include "ChunkFile.h"
#define MAX_WIIMOTES 4
@ -25,7 +26,7 @@ void Shutdown();
void Initialize(void* const hwnd);
unsigned int GetAttached();
void DoState(unsigned char **ptr, int mode);
void DoState(u8 **ptr, PointerWrap::Mode mode);
void EmuStateChange(EMUSTATE_CHANGE newState);
InputPlugin *GetPlugin();

View File

@ -58,6 +58,7 @@ typedef DWORD (__stdcall *PBth_BluetoothGetRadioInfo)(HANDLE, PBLUETOOTH_RADIO_I
typedef DWORD (__stdcall *PBth_BluetoothRemoveDevice)(const BLUETOOTH_ADDRESS*);
typedef DWORD (__stdcall *PBth_BluetoothSetServiceState)(HANDLE, const BLUETOOTH_DEVICE_INFO*, const GUID*, DWORD);
typedef DWORD (__stdcall *PBth_BluetoothAuthenticateDevice)(HWND, HANDLE, BLUETOOTH_DEVICE_INFO*, PWCHAR, ULONG);
typedef DWORD (__stdcall *PBth_BluetoothEnumerateInstalledServices)(HANDLE, BLUETOOTH_DEVICE_INFO*, DWORD*, GUID*);
PHidD_GetHidGuid HidD_GetHidGuid = NULL;
PHidD_GetAttributes HidD_GetAttributes = NULL;
@ -73,6 +74,7 @@ PBth_BluetoothGetRadioInfo Bth_BluetoothGetRadioInfo = NULL;
PBth_BluetoothRemoveDevice Bth_BluetoothRemoveDevice = NULL;
PBth_BluetoothSetServiceState Bth_BluetoothSetServiceState = NULL;
PBth_BluetoothAuthenticateDevice Bth_BluetoothAuthenticateDevice = NULL;
PBth_BluetoothEnumerateInstalledServices Bth_BluetoothEnumerateInstalledServices = NULL;
HINSTANCE hid_lib = NULL;
HINSTANCE bthprops_lib = NULL;
@ -118,12 +120,14 @@ inline void init_lib()
Bth_BluetoothRemoveDevice = (PBth_BluetoothRemoveDevice)GetProcAddress(bthprops_lib, "BluetoothRemoveDevice");
Bth_BluetoothSetServiceState = (PBth_BluetoothSetServiceState)GetProcAddress(bthprops_lib, "BluetoothSetServiceState");
Bth_BluetoothAuthenticateDevice = (PBth_BluetoothAuthenticateDevice)GetProcAddress(bthprops_lib, "BluetoothAuthenticateDevice");
Bth_BluetoothEnumerateInstalledServices = (PBth_BluetoothEnumerateInstalledServices)GetProcAddress(bthprops_lib, "BluetoothEnumerateInstalledServices");
if (!Bth_BluetoothFindDeviceClose || !Bth_BluetoothFindFirstDevice ||
!Bth_BluetoothFindFirstRadio || !Bth_BluetoothFindNextDevice ||
!Bth_BluetoothFindNextRadio || !Bth_BluetoothFindRadioClose ||
!Bth_BluetoothGetRadioInfo || !Bth_BluetoothRemoveDevice ||
!Bth_BluetoothSetServiceState || !Bth_BluetoothAuthenticateDevice)
!Bth_BluetoothSetServiceState || !Bth_BluetoothAuthenticateDevice ||
!Bth_BluetoothEnumerateInstalledServices)
{
PanicAlertT("Failed to load bthprops.cpl");
exit(EXIT_FAILURE);
@ -556,6 +560,14 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info, BLUETO
if (ERROR_SUCCESS != auth_result)
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDevice returned %08x", auth_result);
DWORD pcServices = 16;
GUID guids[16];
// If this is not done, the Wii device will not remember the pairing
const DWORD srv_result = Bth_BluetoothEnumerateInstalledServices(hRadio, &btdi, &pcServices, guids);
if (ERROR_SUCCESS != srv_result)
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned %08x", srv_result);
#endif
// Activate service
const DWORD hr = Bth_BluetoothSetServiceState(hRadio, &btdi,

View File

@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;
// Don't forget to increase this after doing changes on the savestate system
static const u32 STATE_VERSION = 14;
static const u32 STATE_VERSION = 16;
struct StateHeader
{

View File

@ -49,7 +49,8 @@ WiiWAD::WiiWAD(const std::string& _rName)
if (pReader == NULL || File::IsDirectory(_rName))
{
m_Valid = false;
return;
if(pReader) delete pReader;
return;
}
m_Valid = ParseWAD(*pReader);

View File

@ -247,7 +247,7 @@ wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Styl
#else
TC->SetBackgroundColour(*wxBLACK);
#endif
if (m_FontChoice && m_FontChoice->GetSelection() < (int)LogFont.size())
if (m_FontChoice && m_FontChoice->GetSelection() < (int)LogFont.size() && m_FontChoice->GetSelection() >= 0)
TC->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
return TC;

View File

@ -69,6 +69,7 @@ bool Keyboard::UpdateInput()
CGRectMakeWithDictionaryRepresentation(boundsDictionary, &bounds);
}
CFRelease(windowDescriptions);
CFRelease(windowArray);
CGEventRef event = CGEventCreate(nil);

View File

@ -16,6 +16,7 @@ set(SRCS Src/BPFunctions.cpp
Src/OpcodeDecoding.cpp
Src/OpenCL.cpp
Src/OpenCL/OCLTextureDecoder.cpp
Src/PerfQueryBase.cpp
Src/PixelEngine.cpp
Src/PixelShaderGen.cpp
Src/PixelShaderManager.cpp

View File

@ -62,7 +62,7 @@
#define BPMEM_COPYFILTER1 0x54
#define BPMEM_CLEARBBOX1 0x55
#define BPMEM_CLEARBBOX2 0x56
#define BPMEM_UNKNOWN_57 0x57
#define BPMEM_CLEAR_PIXEL_PERF 0x57
#define BPMEM_REVBITS 0x58
#define BPMEM_SCISSOROFFSET 0x59
#define BPMEM_PRELOAD_ADDR 0x60

View File

@ -31,6 +31,7 @@
#include "VertexShaderManager.h"
#include "Thread.h"
#include "HW/Memmap.h"
#include "PerfQueryBase.h"
using namespace BPFunctions;
@ -62,7 +63,6 @@ void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xf
{
Renderer::RenderToXFB(xfbAddr, dstWidth, dstHeight, rc, gamma);
}
void BPWritten(const BPCmd& bp)
{
/*
@ -144,7 +144,8 @@ void BPWritten(const BPCmd& bp)
|| bp.address == BPMEM_LOADTLUT0
|| bp.address == BPMEM_LOADTLUT1
|| bp.address == BPMEM_TEXINVALIDATE
|| bp.address == BPMEM_PRELOAD_MODE))
|| bp.address == BPMEM_PRELOAD_MODE
|| bp.address == BPMEM_CLEAR_PIXEL_PERF))
{
return;
}
@ -484,9 +485,10 @@ void BPWritten(const BPCmd& bp)
case BPMEM_IND_IMASK: // Index Mask ?
case BPMEM_REVBITS: // Always set to 0x0F when GX_InitRevBits() is called.
break;
case BPMEM_UNKNOWN_57: // Sunshine alternates this register between values 0x000 and 0xAAA
DEBUG_LOG(VIDEO, "Unknown BP Reg 0x57: %08x", bp.newvalue);
case BPMEM_CLEAR_PIXEL_PERF:
// GXClearPixMetric writes 0xAAA here, Sunshine alternates this register between values 0x000 and 0xAAA
g_perf_query->ResetQuery();
break;
case BPMEM_PRELOAD_ADDR:

View File

@ -21,6 +21,10 @@ volatile u32 s_swapRequested = false;
u32 s_efbAccessRequested = false;
volatile u32 s_FifoShuttingDown = false;
std::condition_variable s_perf_query_cond;
std::mutex s_perf_query_lock;
static volatile bool s_perf_query_requested;
static volatile struct
{
u32 xfbAddr;
@ -169,6 +173,43 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32
return 0;
}
static bool QueryResultIsReady()
{
return !s_perf_query_requested || s_FifoShuttingDown;
}
void VideoFifo_CheckPerfQueryRequest()
{
if (s_perf_query_requested)
{
g_perf_query->FlushResults();
{
std::lock_guard<std::mutex> lk(s_perf_query_lock);
s_perf_query_requested = false;
}
s_perf_query_cond.notify_one();
}
}
u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
{
// TODO: Is this check sane?
if (!g_perf_query->IsFlushed())
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
{
s_perf_query_requested = true;
std::unique_lock<std::mutex> lk(s_perf_query_lock);
s_perf_query_cond.wait(lk, QueryResultIsReady);
}
else
g_perf_query->FlushResults();
}
return g_perf_query->GetQueryResult(type);
}
void VideoBackendHardware::InitializeShared()
{
@ -176,6 +217,7 @@ void VideoBackendHardware::InitializeShared()
s_swapRequested = 0;
s_efbAccessRequested = 0;
s_perf_query_requested = false;
s_FifoShuttingDown = 0;
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
memset(&s_accessEFBArgs, 0, sizeof(s_accessEFBArgs));
@ -186,6 +228,11 @@ void VideoBackendHardware::InitializeShared()
// Run from the CPU thread
void VideoBackendHardware::DoState(PointerWrap& p)
{
bool software = false;
p.Do(software);
if (p.GetMode() == PointerWrap::MODE_READ && software == true)
// change mode to abort load of incompatible save state.
p.SetMode(PointerWrap::MODE_VERIFY);
VideoCommon_DoState(p);
p.DoMarker("VideoCommon");
@ -233,6 +280,7 @@ void VideoFifo_CheckAsyncRequest()
{
VideoFifo_CheckSwapRequest();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckPerfQueryRequest();
}
void VideoBackendHardware::Video_GatherPipeBursted()

View File

@ -22,7 +22,7 @@ namespace OSD
{
// On-screen message display
void AddMessage(const char* str, u32 ms);
void AddMessage(const char* str, u32 ms = 2000);
void DrawMessages(); // draw the current messages on the screen. Only call once per frame.
void ClearMessages();

View File

@ -0,0 +1,3 @@
#include "PerfQueryBase.h"
PerfQueryBase* g_perf_query = 0;

View File

@ -0,0 +1,54 @@
#ifndef _PERFQUERY_BASE_H_
#define _PERFQUERY_BASE_H_
#include "CommonTypes.h"
enum PerfQueryType
{
PQ_ZCOMP_INPUT_ZCOMPLOC = 0,
PQ_ZCOMP_OUTPUT_ZCOMPLOC,
PQ_ZCOMP_INPUT,
PQ_ZCOMP_OUTPUT,
PQ_BLEND_INPUT,
PQ_EFB_COPY_CLOCKS,
PQ_NUM_MEMBERS
};
enum PerfQueryGroup
{
PQG_ZCOMP_ZCOMPLOC,
PQG_ZCOMP,
PQG_EFB_COPY_CLOCKS,
PQG_NUM_MEMBERS,
};
class PerfQueryBase
{
public:
PerfQueryBase() {};
virtual ~PerfQueryBase() {}
// Begin querying the specified value for the following host GPU commands
virtual void EnableQuery(PerfQueryGroup type) {}
// Stop querying the specified value for the following host GPU commands
virtual void DisableQuery(PerfQueryGroup type) {}
// Reset query counters to zero and drop any pending queries
virtual void ResetQuery() {}
// Return the measured value for the specified query type
// NOTE: Called from CPU thread
virtual u32 GetQueryResult(PerfQueryType type) { return 0; }
// Request the value of any pending queries - causes a pipeline flush and thus should be used carefully!
virtual void FlushResults() {}
// True if there are no further pending query results
// NOTE: Called from CPU thread
virtual bool IsFlushed() const { return true; }
};
extern PerfQueryBase* g_perf_query;
#endif // _PERFQUERY_H_

View File

@ -28,10 +28,13 @@
#include "ConfigManager.h"
#include "PixelEngine.h"
#include "RenderBase.h"
#include "CommandProcessor.h"
#include "HW/ProcessorInterface.h"
#include "DLCache.h"
#include "State.h"
#include "PerfQueryBase.h"
namespace PixelEngine
{
@ -255,23 +258,59 @@ void Read16(u16& _uReturnValue, const u32 _iAddress)
break;
}
case PE_PERF_0L:
case PE_PERF_0H:
case PE_PERF_1L:
case PE_PERF_1H:
case PE_PERF_2L:
case PE_PERF_2H:
case PE_PERF_3L:
case PE_PERF_3H:
case PE_PERF_4L:
case PE_PERF_4H:
case PE_PERF_5L:
case PE_PERF_5H:
INFO_LOG(PIXELENGINE, "(r16) perf counter @ %08x", _iAddress);
// git r90a2096a24f4 (svn r3663) added the PE_PERF cases, without setting
// _uReturnValue to anything, this reverts to the previous behaviour which allows
// The timer in SMS:Scrubbing Serena Beach to countdown correctly
_uReturnValue = 1;
// NOTE(neobrain): only PE_PERF_ZCOMP_OUTPUT is implemented in D3D11, but the other values shouldn't be contradictionary to the value of that register (i.e. INPUT registers should always be greater or equal to their corresponding OUTPUT registers).
case PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT_ZCOMPLOC) & 0xFFFF;
break;
case PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT_ZCOMPLOC) >> 16;
break;
case PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT_ZCOMPLOC) & 0xFFFF;
break;
case PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT_ZCOMPLOC) >> 16;
break;
case PE_PERF_ZCOMP_INPUT_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT) & 0xFFFF;
break;
case PE_PERF_ZCOMP_INPUT_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT) >> 16;
break;
case PE_PERF_ZCOMP_OUTPUT_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT) & 0xFFFF;
break;
case PE_PERF_ZCOMP_OUTPUT_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT) >> 16;
break;
case PE_PERF_BLEND_INPUT_L:
// Super Mario Sunshine uses this register in episode 6 of Sirena Beach:
// The amount of remaining goop is determined by checking how many pixels reach the blending stage.
// Once this register falls below a particular value (around 0x90), the game regards the challenge finished.
// In very old builds, Dolphin only returned 0. That caused the challenge to be immediately finished without any goop being cleaned (the timer just didn't even start counting from 3:00:00).
// Later builds returned 1 for the high register. That caused the timer to actually count down, but made the challenge unbeatable because the game always thought you didn't clear any goop at all.
// Note that currently this functionality is only implemented in the D3D11 backend.
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_BLEND_INPUT) & 0xFFFF;
break;
case PE_PERF_BLEND_INPUT_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_BLEND_INPUT) >> 16;
break;
case PE_PERF_EFB_COPY_CLOCKS_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_EFB_COPY_CLOCKS) & 0xFFFF;
break;
case PE_PERF_EFB_COPY_CLOCKS_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_EFB_COPY_CLOCKS) >> 16;
break;
default:

View File

@ -36,19 +36,20 @@ enum
PE_BBOX_TOP = 0x14, // Flip Top
PE_BBOX_BOTTOM = 0x16, // Flip Bottom
// These have not yet been RE:d. They are the perf counters.
PE_PERF_0L = 0x18,
PE_PERF_0H = 0x1a,
PE_PERF_1L = 0x1c,
PE_PERF_1H = 0x1e,
PE_PERF_2L = 0x20,
PE_PERF_2H = 0x22,
PE_PERF_3L = 0x24,
PE_PERF_3H = 0x26,
PE_PERF_4L = 0x28,
PE_PERF_4H = 0x2a,
PE_PERF_5L = 0x2c,
PE_PERF_5H = 0x2e,
// NOTE: Order not verified
// These indicate the number of quads that are being used as input/output for each particular stage
PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L = 0x18,
PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H = 0x1a,
PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L = 0x1c,
PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H = 0x1e,
PE_PERF_ZCOMP_INPUT_L = 0x20,
PE_PERF_ZCOMP_INPUT_H = 0x22,
PE_PERF_ZCOMP_OUTPUT_L = 0x24,
PE_PERF_ZCOMP_OUTPUT_H = 0x26,
PE_PERF_BLEND_INPUT_L = 0x28,
PE_PERF_BLEND_INPUT_H = 0x2a,
PE_PERF_EFB_COPY_CLOCKS_L = 0x2c,
PE_PERF_EFB_COPY_CLOCKS_H = 0x2e,
};
namespace PixelEngine

View File

@ -52,6 +52,15 @@ public:
Renderer();
virtual ~Renderer();
enum PixelPerfQuery {
PP_ZCOMP_INPUT_ZCOMPLOC,
PP_ZCOMP_OUTPUT_ZCOMPLOC,
PP_ZCOMP_INPUT,
PP_ZCOMP_OUTPUT,
PP_BLEND_INPUT,
PP_EFB_COPY_CLOCKS
};
virtual void SetColorMask() = 0;
virtual void SetBlendMode(bool forceUpdate) = 0;
virtual void SetScissorRect(const TargetRectangle& rc) = 0;

View File

@ -132,8 +132,7 @@ void TextureCache::Cleanup()
if ( frameCount > TEXTURE_KILL_THRESHOLD + iter->second->frameCount
// EFB copies living on the host GPU are unrecoverable and thus shouldn't be deleted
// TODO: encoding the texture back to RAM here might be a good idea
&& ! (g_ActiveConfig.bCopyEFBToTexture && iter->second->IsEfbCopy()) )
&& ! iter->second->IsEfbCopy() )
{
delete iter->second;
textures.erase(iter++);

View File

@ -257,7 +257,9 @@ void VertexManager::Flush()
//if (g_nativeVertexFmt)
g_nativeVertexFmt->SetupVertexPointers();
g_renderer->ResumePixelPerf(false);
g_vertex_manager->Draw(stride, false);
g_renderer->PausePixelPerf(false);
// run through vertex groups again to set alpha
if (false == g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)

View File

@ -115,7 +115,7 @@ struct VideoConfig
int iAnaglyphStereoSeparation;
int iAnaglyphFocalAngle;
bool b3DVision;
// Hacks
bool bEFBAccessEnable;
bool bDlistCachingEnable;

View File

@ -196,6 +196,7 @@
<ClCompile Include="Src\OpcodeDecoding.cpp" />
<ClCompile Include="Src\OpenCL.cpp" />
<ClCompile Include="Src\OpenCL\OCLTextureDecoder.cpp" />
<ClCompile Include="Src\PerfQueryBase.cpp" />
<ClCompile Include="Src\PixelEngine.cpp" />
<ClCompile Include="Src\PixelShaderGen.cpp" />
<ClCompile Include="Src\PixelShaderManager.cpp" />
@ -244,6 +245,7 @@
<ClInclude Include="Src\OpcodeDecoding.h" />
<ClInclude Include="Src\OpenCL.h" />
<ClInclude Include="Src\OpenCL\OCLTextureDecoder.h" />
<ClInclude Include="Src\PerfQueryBase.h" />
<ClInclude Include="Src\PixelEngine.h" />
<ClInclude Include="Src\PixelShaderGen.h" />
<ClInclude Include="Src\PixelShaderManager.h" />

View File

@ -101,6 +101,9 @@
<ClCompile Include="Src\MainBase.cpp">
<Filter>Base</Filter>
</ClCompile>
<ClCompile Include="Src\PerfQueryBase.cpp">
<Filter>Base</Filter>
</ClCompile>
<ClCompile Include="Src\RenderBase.cpp">
<Filter>Base</Filter>
</ClCompile>
@ -237,6 +240,9 @@
<ClInclude Include="Src\MainBase.h">
<Filter>Base</Filter>
</ClInclude>
<ClInclude Include="Src\PerfQueryBase.h">
<Filter>Base</Filter>
</ClInclude>
<ClInclude Include="Src\RenderBase.h">
<Filter>Base</Filter>
</ClInclude>
@ -285,4 +291,4 @@
<UniqueIdentifier>{e2a527a2-ccc8-4ab8-a93e-dd2628c0f3b6}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>