diff --git a/plugins/GSdx/GPU.cpp b/plugins/GSdx/GPU.cpp index d9ea74a71c..63ab5b5309 100644 --- a/plugins/GSdx/GPU.cpp +++ b/plugins/GSdx/GPU.cpp @@ -239,9 +239,7 @@ EXPORT_C GPUupdateLace() EXPORT_C GPUmakeSnapshot() { - LPCTSTR path = _T("C:\\"); // TODO - - s_gpu->MakeSnapshot(path); + s_gpu->MakeSnapshot("c:\\"); // TODO } EXPORT_C GPUdisplayText(char* text) diff --git a/plugins/GSdx/GPULocalMemory.cpp b/plugins/GSdx/GPULocalMemory.cpp index f5a1b8a6ec..4dcdc97975 100644 --- a/plugins/GSdx/GPULocalMemory.cpp +++ b/plugins/GSdx/GPULocalMemory.cpp @@ -568,7 +568,7 @@ void GPULocalMemory::Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int } } -void GPULocalMemory::SaveBMP(LPCTSTR path, CRect r, int tp, int cx, int cy) +void GPULocalMemory::SaveBMP(const string& path, CRect r, int tp, int cx, int cy) { r.left <<= m_scale.cx; r.top <<= m_scale.cy; @@ -578,7 +578,7 @@ void GPULocalMemory::SaveBMP(LPCTSTR path, CRect r, int tp, int cx, int cy) r.left &= ~1; r.right &= ~1; - if(FILE* fp = _tfopen(path, _T("wb"))) + if(FILE* fp = fopen(path.c_str(), "wb")) { BITMAPINFOHEADER bih; memset(&bih, 0, sizeof(bih)); diff --git a/plugins/GSdx/GPULocalMemory.h b/plugins/GSdx/GPULocalMemory.h index 4d7111e7d4..a4adfb4855 100644 --- a/plugins/GSdx/GPULocalMemory.h +++ b/plugins/GSdx/GPULocalMemory.h @@ -79,7 +79,7 @@ public: void Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int pixels); void Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int pixels); - void SaveBMP(LPCTSTR path, CRect r, int tp, int cx, int cy); + void SaveBMP(const string& path, CRect r, int tp, int cx, int cy); }; #pragma warning(default: 4244) \ No newline at end of file diff --git a/plugins/GSdx/GPURenderer.cpp b/plugins/GSdx/GPURenderer.cpp index 8680530c07..e6cd2ade78 100644 --- a/plugins/GSdx/GPURenderer.cpp +++ b/plugins/GSdx/GPURenderer.cpp @@ -22,4 +22,4 @@ #include "StdAfx.h" #include "GPURenderer.h" -CAtlMap GPURendererBase::m_wnd2gpu; \ No newline at end of file +map GPURendererBase::m_wnd2gpu; \ No newline at end of file diff --git a/plugins/GSdx/GPURenderer.h b/plugins/GSdx/GPURenderer.h index 17df468a44..9adaa4968a 100644 --- a/plugins/GSdx/GPURenderer.h +++ b/plugins/GSdx/GPURenderer.h @@ -38,13 +38,15 @@ class GPURendererBase : public GPUState, protected GPURendererSettings protected: HWND m_hWnd; WNDPROC m_wndproc; - static CAtlMap m_wnd2gpu; + static map m_wnd2gpu; static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - if(CAtlMap::CPair* pair = m_wnd2gpu.Lookup(hWnd)) + map::iterator i = m_wnd2gpu.find(hWnd); + + if(i != m_wnd2gpu.end()) { - return pair->m_value->OnMessage(message, wParam, lParam); + return (*i).second->OnMessage(message, wParam, lParam); } ASSERT(0); @@ -92,7 +94,7 @@ public: { SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, (LONG_PTR)m_wndproc); - m_wnd2gpu.RemoveKey(m_hWnd); + m_wnd2gpu.erase(m_hWnd); } } @@ -102,7 +104,8 @@ public: m_wndproc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC); SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)WndProc); - m_wnd2gpu.SetAt(hWnd, this); + + m_wnd2gpu[hWnd] = this; DWORD style = GetWindowLong(hWnd, GWL_STYLE); style |= WS_OVERLAPPEDWINDOW; @@ -115,7 +118,7 @@ public: } virtual void VSync() = 0; - virtual bool MakeSnapshot(LPCTSTR path) = 0; + virtual bool MakeSnapshot(const string& path) = 0; }; template @@ -207,7 +210,7 @@ protected: if(m_count > 0) { /* - Dump(_T("db")); + Dump("db"); if(m_env.PRIM.TME) { @@ -218,9 +221,7 @@ protected: r.right = r.left + 256; r.bottom = r.top + 256; - CString str; - str.Format(_T("da_%d_%d_%d_%d_%d"), m_env.STATUS.TP, r); - Dump(str, m_env.STATUS.TP, r, false); + Dump(format("da_%d_%d_%d_%d_%d", m_env.STATUS.TP, r).c_str(), m_env.STATUS.TP, r, false); } */ @@ -228,7 +229,7 @@ protected: m_count = 0; - //Dump(_T("dc"), false); + //Dump("dc", false); } } @@ -334,7 +335,7 @@ public: // osd static UINT64 s_frame = 0; - static CString s_stats; + static string s_stats; if(m_perfmon.GetFrame() - s_frame >= 30) { @@ -349,8 +350,8 @@ public: int w = r.Width() << m_scale.cx; int h = r.Height() << m_scale.cy; - s_stats.Format( - _T("%I64d | %d x %d | %.2f fps (%d%%) | %d/%d | %d%% CPU | %.2f | %.2f"), + s_stats = format( + "%I64d | %d x %d | %.2f fps (%d%%) | %d/%d | %d%% CPU | %.2f | %.2f", m_perfmon.GetFrame(), w, h, fps, (int)(100.0 * fps / m_env.GetFPS()), (int)m_perfmon.Get(GSPerfMon::Prim), (int)m_perfmon.Get(GSPerfMon::Draw), @@ -363,10 +364,10 @@ public: if(fillrate > 0) { - s_stats.Format(_T("%s | %.2f mpps"), CString(s_stats), fps * fillrate / (1024 * 1024)); + s_stats = format("%s | %.2f mpps", s_stats.c_str(), fps * fillrate / (1024 * 1024)); } - SetWindowText(m_hWnd, s_stats); + SetWindowText(m_hWnd, s_stats.c_str()); } if(m_dev.IsLost()) @@ -383,12 +384,8 @@ public: m_dev.Present(r); } - virtual bool MakeSnapshot(LPCTSTR path) + virtual bool MakeSnapshot(const string& path) { - CString fn; - - fn.Format(_T("%s_%s"), path, CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S"))); - - return m_dev.SaveCurrent(fn + _T(".bmp")); + return m_dev.SaveCurrent(format("%s_%s", path.c_str(), CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S"))) + ".bmp"); } }; diff --git a/plugins/GSdx/GPUSettingsDlg.cpp b/plugins/GSdx/GPUSettingsDlg.cpp index 0d937ad0f2..0bccfa1d53 100644 --- a/plugins/GSdx/GPUSettingsDlg.cpp +++ b/plugins/GSdx/GPUSettingsDlg.cpp @@ -136,17 +136,17 @@ BOOL GPUSettingsDlg::OnInitDialog() memset(&caps, 0, sizeof(caps)); caps.PixelShaderVersion = D3DPS_VERSION(0, 0); - m_modes.RemoveAll(); + m_modes.clear(); // windowed { D3DDISPLAYMODE mode; memset(&mode, 0, sizeof(mode)); - m_modes.AddTail(mode); + m_modes.push_back(mode); int iItem = m_resolution.AddString(_T("Windowed")); - m_resolution.SetItemDataPtr(iItem, m_modes.GetTailPosition()); + m_resolution.SetItemDataPtr(iItem, &m_modes.back()); m_resolution.SetCurSel(iItem); } @@ -170,8 +170,8 @@ BOOL GPUSettingsDlg::OnInitDialog() str.Format(_T("%dx%d %dHz"), mode.Width, mode.Height, mode.RefreshRate); int iItem = m_resolution.AddString(str); - m_modes.AddTail(mode); - m_resolution.SetItemDataPtr(iItem, m_modes.GetTailPosition()); + m_modes.push_back(mode); + m_resolution.SetItemDataPtr(iItem, &m_modes.back()); if(ModeWidth == mode.Width && ModeHeight == mode.Height && ModeRefreshRate == mode.RefreshRate) { @@ -185,16 +185,16 @@ BOOL GPUSettingsDlg::OnInitDialog() bool isdx10avail = GSUtil::IsDirect3D10Available(); - CAtlArray renderers; + vector renderers; for(size_t i = 0; i < countof(g_renderers); i++) { if(i == 2 && !isdx10avail) continue; - renderers.Add(g_renderers[i]); + renderers.push_back(g_renderers[i]); } - GSSetting::InitComboBox(renderers.GetData(), renderers.GetCount(), m_renderer, pApp->GetProfileInt(_T("GPUSettings"), _T("Renderer"), 1)); + GSSetting::InitComboBox(&renderers[0], renderers.size(), m_renderer, pApp->GetProfileInt(_T("GPUSettings"), _T("Renderer"), 1)); GSSetting::InitComboBox(g_psversion, countof(g_psversion), m_psversion, pApp->GetProfileInt(_T("Settings"), _T("PixelShaderVersion2"), D3DPS_VERSION(2, 0)), caps.PixelShaderVersion); GSSetting::InitComboBox(g_filter, countof(g_filter), m_filter, pApp->GetProfileInt(_T("GPUSettings"), _T("filter"), 0)); GSSetting::InitComboBox(g_dithering, countof(g_dithering), m_dithering, pApp->GetProfileInt(_T("GPUSettings"), _T("dithering"), 1)); @@ -225,7 +225,8 @@ void GPUSettingsDlg::OnOK() if(m_resolution.GetCurSel() >= 0) { - D3DDISPLAYMODE& mode = m_modes.GetAt((POSITION)m_resolution.GetItemData(m_resolution.GetCurSel())); + D3DDISPLAYMODE& mode = *(D3DDISPLAYMODE*)m_resolution.GetItemData(m_resolution.GetCurSel()); + pApp->WriteProfileInt(_T("Settings"), _T("ModeWidth"), mode.Width); pApp->WriteProfileInt(_T("Settings"), _T("ModeHeight"), mode.Height); pApp->WriteProfileInt(_T("Settings"), _T("ModeRefreshRate"), mode.RefreshRate); diff --git a/plugins/GSdx/GPUSettingsDlg.h b/plugins/GSdx/GPUSettingsDlg.h index 4602ef685b..04828cf892 100644 --- a/plugins/GSdx/GPUSettingsDlg.h +++ b/plugins/GSdx/GPUSettingsDlg.h @@ -29,7 +29,7 @@ class GPUSettingsDlg : public CDialog DECLARE_DYNAMIC(GPUSettingsDlg) private: - CAtlList m_modes; + list m_modes; public: GPUSettingsDlg(CWnd* pParent = NULL); // standard constructor diff --git a/plugins/GSdx/GPUState.cpp b/plugins/GSdx/GPUState.cpp index 8aa4d30ea3..a8e7630f22 100644 --- a/plugins/GSdx/GPUState.cpp +++ b/plugins/GSdx/GPUState.cpp @@ -356,7 +356,7 @@ int GPUState::PH_Command(GPUReg* r, int size) Invalidate(r2); - Dump(_T("f")); + Dump("f"); return 3; } @@ -568,7 +568,7 @@ int GPUState::PH_Move(GPUReg* r, int size) Invalidate(CRect(dst, CSize(w, h))); - // Dump(_T("m")); + // Dump("m"); return 4; } @@ -597,7 +597,7 @@ int GPUState::PH_Write(GPUReg* r, int size) Invalidate(r2); - Dump(_T("w")); + Dump("w"); m_perfmon.Put(GSPerfMon::Swizzle, w * h * 2); @@ -626,7 +626,7 @@ int GPUState::PH_Read(GPUReg* r, int size) m_mem.ReadRect(r2, (WORD*)m_read.buff); - Dump(_T("r")); + Dump("r"); m_env.STATUS.IMG = 1; diff --git a/plugins/GSdx/GPUState.h b/plugins/GSdx/GPUState.h index 8888dd7ce3..82d93692fd 100644 --- a/plugins/GSdx/GPUState.h +++ b/plugins/GSdx/GPUState.h @@ -88,7 +88,7 @@ protected: int s_n; - void Dump(LPCTSTR s, UINT32 TP, const CRect& r, int inc = true) + void Dump(const string& s, UINT32 TP, const CRect& r, int inc = true) { //if(m_perfmon.GetFrame() < 1000) //if((m_env.TWIN.ai32 & 0xfffff) == 0) @@ -103,12 +103,10 @@ protected: #ifdef DEBUG dir = 2; #endif - CString str; - str.Format(_T("c:\\temp%d\\%04d_%s.bmp"), dir, s_n, s); - m_mem.SaveBMP(str, r, TP, m_env.CLUT.X, m_env.CLUT.Y); + m_mem.SaveBMP(format("c:\\temp%d\\%04d_%s.bmp", dir, s_n, s), r, TP, m_env.CLUT.X, m_env.CLUT.Y); } - void Dump(LPCTSTR s, int inc = true) + void Dump(const string& s, int inc = true) { Dump(s, 2, CRect(0, 0, 1024, 512), inc); } diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 3dd274f709..c4fce6e68a 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -133,7 +133,7 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer) s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); - if(!s_gs->Create(CString(title))) + if(!s_gs->Create(title)) { GSclose(); @@ -152,15 +152,21 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer) EXPORT_C_(INT32) GSopen(void* dsp, char* title, int mt) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); + int renderer; - if (mt == 2){ //pcsx2 sent a switch renderer request + if(mt == 2) + { + // pcsx2 sent a switch renderer request renderer = 1; //DX9 sw mt = 1; } - else { //normal init + else + { + // normal init renderer = AfxGetApp()->GetProfileInt(_T("Settings"), _T("renderer"), 0); } + return GSopen(dsp, title, mt, renderer); } @@ -211,7 +217,7 @@ EXPORT_C GSvsync(int field) EXPORT_C_(UINT32) GSmakeSnapshot(char* path) { - return s_gs->MakeSnapshot(CString(path) + _T("gsdx")); + return s_gs->MakeSnapshot(string(path) + "gsdx"); } EXPORT_C GSkeyEvent(keyEvent* ev) @@ -303,7 +309,7 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); - CAtlArray buff; + vector buff; if(FILE* fp = fopen(lpszCmdLine, "rb")) { @@ -313,7 +319,7 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) GSsetBaseMem(regs); HWND hWnd = NULL; - GSopen(&hWnd, _T(""), true, renderer); + GSopen(&hWnd, "", true, renderer); DWORD crc; fread(&crc, 4, 1, fp); @@ -348,20 +354,20 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) switch(index) { case 0: - if(buff.GetCount() < 0x4000) buff.SetCount(0x4000); + if(buff.size() < 0x4000) buff.resize(0x4000); addr = 0x4000 - size; - fread(buff.GetData() + addr, size, 1, fp); - GSgifTransfer1(buff.GetData(), addr); + fread(&buff[0] + addr, size, 1, fp); + GSgifTransfer1(&buff[0], addr); break; case 1: - if(buff.GetCount() < size) buff.SetCount(size); - fread(buff.GetData(), size, 1, fp); - GSgifTransfer2(buff.GetData(), size / 16); + if(buff.size() < size) buff.resize(size); + fread(&buff[0], size, 1, fp); + GSgifTransfer2(&buff[0], size / 16); break; case 2: - if(buff.GetCount() < size) buff.SetCount(size); - fread(buff.GetData(), size, 1, fp); - GSgifTransfer3(buff.GetData(), size / 16); + if(buff.size() < size) buff.resize(size); + fread(&buff[0], size, 1, fp); + GSgifTransfer3(&buff[0], size / 16); break; } break; @@ -371,8 +377,8 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) break; case 2: fread(&size, 4, 1, fp); - if(buff.GetCount() < size) buff.SetCount(size); - GSreadFIFO2(buff.GetData(), size / 16); + if(buff.size() < size) buff.resize(size); + GSreadFIFO2(&buff[0], size / 16); break; case 3: fread(regs, 0x2000, 1, fp); @@ -394,15 +400,15 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow { ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); - FILE* file = _tfopen(_T("c:\\log.txt"), _T("a")); + FILE* file = fopen("c:\\log.txt", "a"); - _ftprintf(file, _T("-------------------------\n\n")); + fprintf(file, "-------------------------\n\n"); if(1) { GSLocalMemory mem; - static struct {int psm; LPCSTR name;} s_format[] = + static struct {int psm; const char* name;} s_format[] = { {PSM_PSMCT32, "32"}, {PSM_PSMCT24, "24"}, @@ -432,7 +438,7 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow int w = 1 << tbw; int h = 1 << tbw; - _ftprintf(file, _T("%d x %d\n\n"), w, h); + fprintf(file, "%d x %d\n\n", w, h); for(int i = 0; i < countof(s_format); i++) { @@ -496,7 +502,7 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow end = clock(); - _ftprintf(file, _T("%6d %6d | "), (int)((float)trlen * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); + fprintf(file, "%6d %6d | ", (int)((float)trlen * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); start = clock(); @@ -510,7 +516,7 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow end = clock(); - _ftprintf(file, _T("%6d %6d | "), (int)((float)trlen * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); + fprintf(file, "%6d %6d | ", (int)((float)trlen * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); start = clock(); @@ -521,7 +527,7 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow end = clock(); - _ftprintf(file, _T("%6d %6d "), (int)((float)len * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); + fprintf(file, "%6d %6d ", (int)((float)len * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); if(psm.pal > 0) { @@ -534,15 +540,15 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow end = clock(); - _ftprintf(file, _T("| %6d %6d "), (int)((float)len * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); + fprintf(file, "| %6d %6d ", (int)((float)len * n / (end - start) / 1000), (int)((float)(w * h) * n / (end - start) / 1000)); } - _ftprintf(file, _T("\n")); + fprintf(file, "\n"); fflush(file); } - _ftprintf(file, _T("\n")); + fprintf(file, "\n"); } _aligned_free(ptr); diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index bd1ccca41e..069e71841b 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -60,7 +60,7 @@ GSSource : public CBaseFilter, private CCritSec, public IGSSource class GSSourceOutputPin : public CBaseOutputPin { CSize m_size; - CAtlArray m_mts; + vector m_mts; public: GSSourceOutputPin(CSize size, REFERENCE_TIME atpf, CBaseFilter* pFilter, CCritSec* pLock, HRESULT& hr) @@ -91,7 +91,7 @@ GSSource : public CBaseFilter, private CCritSec, public IGSSource vih.bmiHeader.biSizeImage = m_size.cx * m_size.cy * 2; mt.SetFormat((BYTE*)&vih, sizeof(vih)); - m_mts.Add(mt); + m_mts.push_back(mt); #endif @@ -106,7 +106,7 @@ GSSource : public CBaseFilter, private CCritSec, public IGSSource vih.bmiHeader.biSizeImage = m_size.cx * m_size.cy * 4; mt.SetFormat((BYTE*)&vih, sizeof(vih)); - m_mts.Add(mt); + m_mts.push_back(mt); } HRESULT GSSourceOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties) @@ -137,9 +137,9 @@ GSSource : public CBaseFilter, private CCritSec, public IGSSource HRESULT CheckMediaType(const CMediaType* pmt) { - for(int i = 0, j = m_mts.GetCount(); i < j; i++) + for(vector::iterator i = m_mts.begin(); i != m_mts.end(); i++) { - if(m_mts[i].majortype == pmt->majortype && m_mts[i].subtype == pmt->subtype) + if(i->majortype == pmt->majortype && i->subtype == pmt->subtype) { return S_OK; } diff --git a/plugins/GSdx/GSCaptureDlg.cpp b/plugins/GSdx/GSCaptureDlg.cpp index 8dcd094875..32432a5df4 100644 --- a/plugins/GSdx/GSCaptureDlg.cpp +++ b/plugins/GSdx/GSCaptureDlg.cpp @@ -44,11 +44,11 @@ int GSCaptureDlg::GetSelCodec(Codec& c) if(iSel < 0) return 0; - POSITION pos = (POSITION)m_codeclist.GetItemDataPtr(iSel); + Codec* codec = (Codec*)m_codeclist.GetItemDataPtr(iSel); - if(pos == NULL) return 2; + if(codec == NULL) return 2; - c = m_codecs.GetAt(pos); + c = *codec; if(!c.filter) { @@ -83,7 +83,7 @@ BOOL GSCaptureDlg::OnInitDialog() { __super::OnInitDialog(); - m_codecs.RemoveAll(); + m_codecs.clear(); m_codeclist.ResetContent(); m_codeclist.SetItemDataPtr(m_codeclist.AddString(_T("Uncompressed")), NULL); @@ -116,7 +116,8 @@ BOOL GSCaptureDlg::OnInitDialog() else if(str.Find(L"@device:cm:") == 0) prefix = _T("(VfW) "); c.FriendlyName = prefix + c.FriendlyName; - m_codeclist.SetItemDataPtr(m_codeclist.AddString(c.FriendlyName), m_codecs.AddTail(c)); + m_codecs.push_back(c); + m_codeclist.SetItemDataPtr(m_codeclist.AddString(c.FriendlyName), &m_codecs.back()); } EndEnumSysDev @@ -128,13 +129,17 @@ BOOL GSCaptureDlg::OnInitDialog() { CString DisplayName; - POSITION pos = (POSITION)m_codeclist.GetItemDataPtr(i); + Codec* codec = (Codec*)m_codeclist.GetItemDataPtr(i); - if(pos) DisplayName = m_codecs.GetAt(pos).DisplayName; + if(codec) + { + DisplayName = codec->DisplayName; + } if(DisplayName == DisplayNameToFind) { m_codeclist.SetCurSel(i); + break; } } diff --git a/plugins/GSdx/GSCaptureDlg.h b/plugins/GSdx/GSCaptureDlg.h index 419b0cd62a..04d7215bd1 100644 --- a/plugins/GSdx/GSCaptureDlg.h +++ b/plugins/GSdx/GSCaptureDlg.h @@ -39,7 +39,7 @@ private: CComBSTR DisplayName; }; - CAtlList m_codecs; + list m_codecs; int GetSelCodec(Codec& c); diff --git a/plugins/GSdx/GSCodeBuffer.cpp b/plugins/GSdx/GSCodeBuffer.cpp index fe8214b97a..7f90f53569 100644 --- a/plugins/GSdx/GSCodeBuffer.cpp +++ b/plugins/GSdx/GSCodeBuffer.cpp @@ -32,9 +32,9 @@ GSCodeBuffer::GSCodeBuffer(size_t blocksize) GSCodeBuffer::~GSCodeBuffer() { - while(!m_buffers.IsEmpty()) + for(list::iterator i = m_buffers.begin(); i != m_buffers.end(); i++) { - VirtualFree(m_buffers.RemoveHead(), 0, MEM_RELEASE); + VirtualFree(*i, 0, MEM_RELEASE); } } @@ -51,7 +51,7 @@ void* GSCodeBuffer::GetBuffer(size_t size) m_pos = 0; - m_buffers.AddTail(m_ptr); + m_buffers.push_back(m_ptr); } BYTE* ptr = &m_ptr[m_pos]; diff --git a/plugins/GSdx/GSCodeBuffer.h b/plugins/GSdx/GSCodeBuffer.h index 5aaed5bc38..7011d00950 100644 --- a/plugins/GSdx/GSCodeBuffer.h +++ b/plugins/GSdx/GSCodeBuffer.h @@ -23,7 +23,7 @@ class GSCodeBuffer { - CAtlList m_buffers; + list m_buffers; size_t m_blocksize; size_t m_pos, m_reserved; BYTE* m_ptr; diff --git a/plugins/GSdx/GSCrc.cpp b/plugins/GSdx/GSCrc.cpp index aec9656c20..85abd05cb5 100644 --- a/plugins/GSdx/GSCrc.cpp +++ b/plugins/GSdx/GSCrc.cpp @@ -131,11 +131,11 @@ CRC::Game CRC::m_games[] = {0xFB236A46, SonicUnleashed, US}, }; -CAtlMap CRC::m_map; +hash_map CRC::m_map; CRC::Game CRC::Lookup(DWORD crc) { - if(m_map.IsEmpty()) + if(m_map.empty()) { for(int i = 0; i < countof(m_games); i++) { @@ -143,9 +143,11 @@ CRC::Game CRC::Lookup(DWORD crc) } } - if(CAtlMap::CPair* pair = m_map.Lookup(crc)) + hash_map::iterator i = m_map.find(crc); + + if(i != m_map.end()) { - return *pair->m_value; + return *(*i).second; } return m_games[0]; diff --git a/plugins/GSdx/GSCrc.h b/plugins/GSdx/GSCrc.h index 083b69df1a..c5187f3b87 100644 --- a/plugins/GSdx/GSCrc.h +++ b/plugins/GSdx/GSCrc.h @@ -91,7 +91,7 @@ public: private: static Game m_games[]; - static CAtlMap m_map; + static hash_map m_map; public: static Game Lookup(DWORD crc); diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index e21f5ffdc4..01d06f42cc 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -46,7 +46,7 @@ struct InterlaceConstantBuffer template class GSDevice { - CAtlList m_pool; + list m_pool; protected: HWND m_hWnd; @@ -62,15 +62,15 @@ protected: { Recycle(t); - for(POSITION pos = m_pool.GetHeadPosition(); pos; m_pool.GetNext(pos)) + for(list::iterator i = m_pool.begin(); i != m_pool.end(); i++) { - const Texture& t2 = m_pool.GetAt(pos); + const Texture& t2 = *i; if(t2.GetType() == type && t2.GetWidth() == w && t2.GetHeight() == h && t2.GetFormat() == format) { t = t2; - m_pool.RemoveAt(pos); + m_pool.erase(i); return true; } @@ -102,7 +102,7 @@ public: virtual bool Reset(int w, int h, bool fs) { - m_pool.RemoveAll(); + m_pool.clear(); m_backbuffer = Texture(); m_merge = Texture(); m_weavebob = Texture(); @@ -121,7 +121,7 @@ public: virtual void EndScene() = 0; - virtual void Draw(LPCTSTR str) = 0; + virtual void Draw(const string& s) = 0; virtual bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0) = 0; @@ -157,18 +157,18 @@ public: { if(t) { - m_pool.AddHead(t); + m_pool.push_front(t); - while(m_pool.GetCount() > 200) + while(m_pool.size() > 200) { - m_pool.RemoveTail(); + m_pool.pop_back(); } t = Texture(); } } - bool SaveCurrent(LPCTSTR fn) + bool SaveCurrent(const string& fn) { return m_current.Save(fn); } diff --git a/plugins/GSdx/GSDevice10.cpp b/plugins/GSdx/GSDevice10.cpp index 5cd874a69d..97465aa013 100644 --- a/plugins/GSdx/GSDevice10.cpp +++ b/plugins/GSdx/GSDevice10.cpp @@ -112,9 +112,7 @@ bool GSDevice10::Create(HWND hWnd, bool vsync) for(int i = 0; i < countof(m_convert.ps); i++) { - CStringA main; - main.Format("ps_main%d", i); - hr = CompileShader(IDR_CONVERT10_FX, main, NULL, &m_convert.ps[i]); + hr = CompileShader(IDR_CONVERT10_FX, format("ps_main%d", i), NULL, &m_convert.ps[i]); } memset(&bd, 0, sizeof(bd)); @@ -155,9 +153,7 @@ bool GSDevice10::Create(HWND hWnd, bool vsync) for(int i = 0; i < countof(m_merge.ps); i++) { - CStringA main; - main.Format("ps_main%d", i); - hr = CompileShader(IDR_MERGE10_FX, main, NULL, &m_merge.ps[i]); + hr = CompileShader(IDR_MERGE10_FX, format("ps_main%d", i), NULL, &m_merge.ps[i]); } memset(&bsd, 0, sizeof(bsd)); @@ -187,9 +183,7 @@ bool GSDevice10::Create(HWND hWnd, bool vsync) for(int i = 0; i < countof(m_interlace.ps); i++) { - CStringA main; - main.Format("ps_main%d", i); - hr = CompileShader(IDR_INTERLACE10_FX, main, NULL, &m_interlace.ps[i]); + hr = CompileShader(IDR_INTERLACE10_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]); } // @@ -298,7 +292,7 @@ void GSDevice10::EndScene() // OMSetRenderTargets(NULL, NULL); } -void GSDevice10::Draw(LPCTSTR str) +void GSDevice10::Draw(const string& s) { /* BOOL fs; @@ -741,13 +735,13 @@ void GSDevice10::StretchRect(Texture& st, const GSVector4& sr, Texture& dt, cons EndScene(); } -HRESULT GSDevice10::CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** ps, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il) +HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** ps, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il) { HRESULT hr; CComPtr shader, error; - hr = D3DX10CompileFromResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry, "vs_4_0", 0, 0, NULL, &shader, &error, NULL); + hr = D3DX10CompileFromResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry.c_str(), "vs_4_0", 0, 0, NULL, &shader, &error, NULL); if(error) { @@ -776,13 +770,13 @@ HRESULT GSDevice10::CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* mac return hr; } -HRESULT GSDevice10::CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs) +HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs) { HRESULT hr; CComPtr shader, error; - hr = D3DX10CompileFromResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry, "gs_4_0", 0, 0, NULL, &shader, &error, NULL); + hr = D3DX10CompileFromResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry.c_str(), "gs_4_0", 0, 0, NULL, &shader, &error, NULL); if(error) { @@ -804,13 +798,13 @@ HRESULT GSDevice10::CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* mac return hr; } -HRESULT GSDevice10::CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps) +HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps) { HRESULT hr; CComPtr shader, error; - hr = D3DX10CompileFromResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry, "ps_4_0", 0, 0, NULL, &shader, &error, NULL); + hr = D3DX10CompileFromResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry.c_str(), "ps_4_0", 0, 0, NULL, &shader, &error, NULL); if(error) { diff --git a/plugins/GSdx/GSDevice10.h b/plugins/GSdx/GSDevice10.h index 55124884de..a3ad0c1a75 100644 --- a/plugins/GSdx/GSDevice10.h +++ b/plugins/GSdx/GSDevice10.h @@ -103,7 +103,7 @@ public: void Present(const CRect& r); void BeginScene(); void EndScene(); - void Draw(LPCTSTR str); + void Draw(const string& s); bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0); void ClearRenderTarget(Texture& t, const GSVector4& c); @@ -138,10 +138,7 @@ public: void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, ID3D10PixelShader* ps, ID3D10Buffer* ps_cb, bool linear = true); void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, ID3D10PixelShader* ps, ID3D10Buffer* ps_cb, ID3D10BlendState* bs, bool linear = true); - HRESULT CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** vs, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il); - HRESULT CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs); - HRESULT CompileShader(UINT id, LPCSTR entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps); - - // TODO - bool SaveToFileD32S8X24(ID3D10Texture2D* ds, LPCTSTR fn); + HRESULT CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** vs, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il); + HRESULT CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs); + HRESULT CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps); }; diff --git a/plugins/GSdx/GSDevice7.h b/plugins/GSdx/GSDevice7.h index 94823dbf88..42d2853cf7 100644 --- a/plugins/GSdx/GSDevice7.h +++ b/plugins/GSdx/GSDevice7.h @@ -48,7 +48,7 @@ public: void Present(const CRect& r); void BeginScene() {} void EndScene() {} - void Draw(LPCTSTR str) {} + void Draw(const string& s) {} bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0) {return false;} void ClearRenderTarget(Texture& t, const GSVector4& c) {} diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 03984fc848..73f46d7482 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -141,9 +141,7 @@ bool GSDevice9::Create(HWND hWnd, bool vsync) for(int i = 0; i < countof(m_convert.ps); i++) { - CStringA main; - main.Format("ps_main%d", i); - CompileShader(IDR_CONVERT9_FX, main, NULL, &m_convert.ps[i]); + CompileShader(IDR_CONVERT9_FX, format("ps_main%d", i), NULL, &m_convert.ps[i]); } m_convert.dss.DepthEnable = false; @@ -170,9 +168,7 @@ bool GSDevice9::Create(HWND hWnd, bool vsync) for(int i = 0; i < countof(m_merge.ps); i++) { - CStringA main; - main.Format("ps_main%d", i); - CompileShader(IDR_MERGE9_FX, main, NULL, &m_merge.ps[i]); + CompileShader(IDR_MERGE9_FX, format("ps_main%d", i), NULL, &m_merge.ps[i]); } m_merge.bs.BlendEnable = true; @@ -188,9 +184,7 @@ bool GSDevice9::Create(HWND hWnd, bool vsync) for(int i = 0; i < countof(m_interlace.ps); i++) { - CStringA main; - main.Format("ps_main%d", i); - CompileShader(IDR_INTERLACE9_FX, main, NULL, &m_interlace.ps[i]); + CompileShader(IDR_INTERLACE9_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]); } // @@ -393,7 +387,7 @@ void GSDevice9::EndScene() m_dev->EndScene(); } -void GSDevice9::Draw(LPCTSTR str) +void GSDevice9::Draw(const string& s) { /* if(!m_pp.Windowed) @@ -941,9 +935,9 @@ static HRESULT LoadShader(UINT id, LPCSTR& data, DWORD& size) return S_OK; } -HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il) +HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il) { - LPCSTR target; + const char* target; if(m_d3dcaps.VertexShaderVersion >= D3DVS_VERSION(3, 0)) { @@ -962,7 +956,7 @@ HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, CComPtr shader, error; - // FIXME: hr = D3DXCompileShaderFromResource(AfxGetResourceHandle(), MAKEINTRESOURCE(id), macro, NULL, entry, target, 0, &shader, &error, NULL); + // FIXME: hr = D3DXCompileShaderFromResource(AfxGetResourceHandle(), MAKEINTRESOURCE(id), macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL); LPCSTR data; DWORD size; @@ -971,7 +965,7 @@ HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, if(FAILED(hr)) return E_FAIL; - hr = D3DXCompileShader(data, size, macro, NULL, entry, target, 0, &shader, &error, NULL); + hr = D3DXCompileShader(data, size, macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL); if(SUCCEEDED(hr)) { @@ -1001,9 +995,9 @@ HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, return S_OK; } -HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps) +HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps) { - LPCSTR target = NULL; + const char* target = NULL; UINT flags = 0; if(m_d3dcaps.PixelShaderVersion >= D3DPS_VERSION(3, 0)) @@ -1024,7 +1018,7 @@ HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, CComPtr shader, error; - // FIXME: hr = D3DXCompileShaderFromResource(AfxGetResourceHandle(), MAKEINTRESOURCE(id), macro, NULL, entry, target, flags, &shader, &error, NULL); + // FIXME: hr = D3DXCompileShaderFromResource(AfxGetResourceHandle(), MAKEINTRESOURCE(id), macro, NULL, entry.c_str(), target, flags, &shader, &error, NULL); LPCSTR data; DWORD size; @@ -1033,7 +1027,7 @@ HRESULT GSDevice9::CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, if(FAILED(hr)) return E_FAIL; - hr = D3DXCompileShader(data, size, macro, NULL, entry, target, 0, &shader, &error, NULL); + hr = D3DXCompileShader(data, size, macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL); if(SUCCEEDED(hr)) { diff --git a/plugins/GSdx/GSDevice9.h b/plugins/GSdx/GSDevice9.h index 5a16aa0106..105b3f72f9 100644 --- a/plugins/GSdx/GSDevice9.h +++ b/plugins/GSdx/GSDevice9.h @@ -139,7 +139,7 @@ public: void Present(const CRect& r); void BeginScene(); void EndScene(); - void Draw(LPCTSTR str); + void Draw(const string& s); bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0); void ClearRenderTarget(Texture& t, const GSVector4& c); @@ -179,14 +179,11 @@ public: void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len, bool linear = true); void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len, Direct3DBlendState9* bs, bool linear = true); - HRESULT CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il); - HRESULT CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps); + HRESULT CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il); + HRESULT CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps); virtual bool IsCurrentRGBA() { return false; } - - // TODO - bool SaveToFileD24S8(IDirect3DSurface9* ds, LPCTSTR fn); }; diff --git a/plugins/GSdx/GSDeviceNull.h b/plugins/GSdx/GSDeviceNull.h index e2782f1228..acd471f71d 100644 --- a/plugins/GSdx/GSDeviceNull.h +++ b/plugins/GSdx/GSDeviceNull.h @@ -43,7 +43,7 @@ public: void Present(const CRect& r) {} void BeginScene() {} void EndScene() {} - void Draw(LPCTSTR str) {} + void Draw(const string& s) {} bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0) {return false;} void ClearRenderTarget(Texture& t, const GSVector4& c) {} diff --git a/plugins/GSdx/GSDirtyRect.cpp b/plugins/GSdx/GSDirtyRect.cpp index 1d8b7ff123..f1d12497bb 100644 --- a/plugins/GSdx/GSDirtyRect.cpp +++ b/plugins/GSdx/GSDirtyRect.cpp @@ -62,9 +62,17 @@ CRect GSDirtyRect::GetDirtyRect(const GIFRegTEX0& TEX0) CRect GSDirtyRectList::GetDirtyRect(const GIFRegTEX0& TEX0, CSize size) { - if(IsEmpty()) return CRect(0, 0, 0, 0); + if(empty()) + { + return CRect(0, 0, 0, 0); + } + CRect r(INT_MAX, INT_MAX, 0, 0); - POSITION pos = GetHeadPosition(); - while(pos) r |= GetNext(pos).GetDirtyRect(TEX0); + + for(list::iterator i = begin(); i != end(); i++) + { + r |= i->GetDirtyRect(TEX0); + } + return r & CRect(0, 0, size.cx, size.cy); } diff --git a/plugins/GSdx/GSDirtyRect.h b/plugins/GSdx/GSDirtyRect.h index 8e6f5734df..a573d79ab2 100644 --- a/plugins/GSdx/GSDirtyRect.h +++ b/plugins/GSdx/GSDirtyRect.h @@ -34,7 +34,7 @@ public: CRect GetDirtyRect(const GIFRegTEX0& TEX0); }; -class GSDirtyRectList : public CAtlList +class GSDirtyRectList : public list { public: GSDirtyRectList() {} diff --git a/plugins/GSdx/GSDump.cpp b/plugins/GSdx/GSDump.cpp index 70421b35db..7f1095a5b3 100644 --- a/plugins/GSdx/GSDump.cpp +++ b/plugins/GSdx/GSDump.cpp @@ -36,10 +36,10 @@ GSDump::~GSDump() Close(); } -void GSDump::Open(const CString& fn, DWORD crc, const GSFreezeData& fd, const GSPrivRegSet* regs) +void GSDump::Open(const string& fn, DWORD crc, const GSFreezeData& fd, const GSPrivRegSet* regs) { - m_gs = _tfopen(fn + _T(".gs"), _T("wb")); - m_obj = _tfopen(fn + _T(".obj"), _T("wt")); + m_gs = fopen((fn + ".gs").c_str(), "wb"); + m_obj = fopen((fn + ".obj").c_str(), "wt"); m_frames = 0; m_objects = 0; @@ -123,20 +123,20 @@ void GSDump::Object(GSVertexSW* vertices, int count, GS_PRIM_CLASS primclass) float y = vertices[i].p.y; float z = vertices[i].p.z; - _ftprintf(m_obj, _T("v %f %f %f\n"), x, y, z); + fprintf(m_obj, "v %f %f %f\n", x, y, z); } for(int i = 0; i < count; i++) { - _ftprintf(m_obj, _T("vt %f %f %f\n"), vertices[i].t.x, vertices[i].t.y, vertices[i].t.z); + fprintf(m_obj, "vt %f %f %f\n", vertices[i].t.x, vertices[i].t.y, vertices[i].t.z); } for(int i = 0; i < count; i++) { - _ftprintf(m_obj, _T("vn %f %f %f\n"), 0.0f, 0.0f, 0.0f); + fprintf(m_obj, "vn %f %f %f\n", 0.0f, 0.0f, 0.0f); } - _ftprintf(m_obj, _T("g f%d_o%d_p%d_v%d\n"), m_frames, m_objects, primclass, count); + fprintf(m_obj, "g f%d_o%d_p%d_v%d\n", m_frames, m_objects, primclass, count); for(int i = 0; i < count; i += 3) { @@ -144,7 +144,7 @@ void GSDump::Object(GSVertexSW* vertices, int count, GS_PRIM_CLASS primclass) int b = m_vertices + i + 2; int c = m_vertices + i + 3; - _ftprintf(m_obj, _T("f %d/%d/%d %d/%d/%d %d/%d/%d \n"), a, a, a, b, b, b, c, c, c); + fprintf(m_obj, "f %d/%d/%d %d/%d/%d %d/%d/%d\n", a, a, a, b, b, b, c, c, c); } m_vertices += count; diff --git a/plugins/GSdx/GSDump.h b/plugins/GSdx/GSDump.h index bfa2d0682b..1ffc8167ec 100644 --- a/plugins/GSdx/GSDump.h +++ b/plugins/GSdx/GSDump.h @@ -55,7 +55,7 @@ public: GSDump(); virtual ~GSDump(); - void Open(const CString& fn, DWORD crc, const GSFreezeData& fd, const GSPrivRegSet* regs); + void Open(const string& fn, DWORD crc, const GSFreezeData& fd, const GSPrivRegSet* regs); void Close(); void ReadFIFO(UINT32 size); void Transfer(int index, BYTE* mem, size_t size); diff --git a/plugins/GSdx/GSFunctionMap.h b/plugins/GSdx/GSFunctionMap.h index a6fb5127d7..34074703d0 100644 --- a/plugins/GSdx/GSFunctionMap.h +++ b/plugins/GSdx/GSFunctionMap.h @@ -22,6 +22,7 @@ #pragma once #include "GS.h" +#include "GSCodeBuffer.h" struct GSRasterizerStats { @@ -50,8 +51,9 @@ protected: VALUE f; }; - CRBMap m_map; - CRBMap m_map_active; + hash_map m_map; + hash_map m_map_active; + ActivePtr* m_active; virtual VALUE GetDefaultFunction(KEY key) = 0; @@ -64,28 +66,25 @@ public: virtual ~GSFunctionMap() { - POSITION pos = m_map_active.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_map_active.begin(); i != m_map_active.end(); i++) { - delete m_map_active.GetNextValue(pos); + delete (*i).second; } - - m_map_active.RemoveAll(); - } - - void SetAt(KEY key, VALUE f) - { - m_map.SetAt(key, f); } VALUE Lookup(KEY key) { m_active = NULL; - if(!m_map_active.Lookup(key, m_active)) + hash_map::iterator i = m_map_active.find(key); + + if(i != m_map_active.end()) { - CRBMap::CPair* pair = m_map.Lookup(key); + m_active = (*i).second; + } + else + { + hash_map::iterator i = m_map.find(key); ActivePtr* p = new ActivePtr(); @@ -93,9 +92,9 @@ public: p->frame = (UINT64)-1; - p->f = pair ? pair->m_value : GetDefaultFunction(key); + p->f = i != m_map.end() ? (*i).second : GetDefaultFunction(key); - m_map_active.SetAt(key, p); + m_map_active[key] = p; m_active = p; } @@ -122,11 +121,9 @@ public: { __int64 ttpf = 0; - POSITION pos = m_map_active.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_map_active.begin(); i != m_map_active.end(); i++) { - ActivePtr* p = m_map_active.GetNextValue(pos); + ActivePtr* p = (*i).second; if(p->frames) { @@ -134,14 +131,10 @@ public: } } - pos = m_map_active.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_map_active.begin(); i != m_map_active.end(); i++) { - KEY key; - ActivePtr* p; - - m_map_active.GetNextAssoc(pos, key, p); + KEY key = (*i).first; + ActivePtr* p = (*i).second; if(p->frames > 0) { @@ -150,7 +143,7 @@ public: __int64 ppf = p->frames > 0 ? p->pixels / p->frames : 0; printf("[%012I64x]%c %6.2f%% | %5.2f%% | f %4I64d | p %10I64d | tpp %4I64d | tpf %9I64d | ppf %7I64d\n", - (UINT64)key, !m_map.Lookup(key) ? '*' : ' ', + (UINT64)key, m_map.find(key) == m_map.end() ? '*' : ' ', (float)(tpf * 10000 / 50000000) / 100, (float)(tpf * 10000 / ttpf) / 100, p->frames, p->pixels, @@ -160,15 +153,14 @@ public: } }; -#include "GSCodeBuffer.h" #include "vtune/JITProfiling.h" template class GSCodeGeneratorFunctionMap : public GSFunctionMap { DWORD m_id; - CStringA m_name; - CRBMap m_cgmap; + string m_name; + hash_map m_cgmap; GSCodeBuffer m_cb; enum {MAX_SIZE = 4096}; @@ -177,7 +169,7 @@ protected: virtual CG* Create(KEY key, void* ptr, size_t maxsize = MAX_SIZE) = 0; public: - GSCodeGeneratorFunctionMap(LPCSTR name) + GSCodeGeneratorFunctionMap(const char* name) : m_id(0x100000) , m_name(name) { @@ -185,11 +177,9 @@ public: virtual ~GSCodeGeneratorFunctionMap() { - POSITION pos = m_cgmap.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_cgmap.begin(); i != m_cgmap.end(); i++) { - delete m_cgmap.GetNextValue(pos); + delete (*i).second; } } @@ -197,7 +187,13 @@ public: { CG* cg = NULL; - if(!m_cgmap.Lookup(key, cg)) + hash_map::iterator i = m_cgmap.find(key); + + if(i != m_cgmap.end()) + { + cg = (*i).second; + } + else { void* ptr = m_cb.GetBuffer(MAX_SIZE); @@ -207,20 +203,18 @@ public: m_cb.ReleaseBuffer(cg->getSize()); - m_cgmap.SetAt(key, cg); + m_cgmap[key] = cg; // vtune method registration - CStringA name; - - name.Format("%s<%016I64x>()", m_name, (UINT64)key); + string name = format("%s<%016I64x>()", m_name.c_str(), (UINT64)key); iJIT_Method_Load ml; memset(&ml, 0, sizeof(ml)); ml.method_id = m_id++; - ml.method_name = (LPSTR)(LPCSTR)name; + ml.method_name = (char*)name.c_str(); ml.method_load_address = (void*)cg->getCode(); ml.method_size = cg->getSize(); diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 1ef3bb5485..4a8a8ebff7 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -465,11 +465,9 @@ GSLocalMemory::~GSLocalMemory() { VirtualFree(m_vm8, 0, MEM_RELEASE); - POSITION pos = m_omap.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_omap.begin(); i != m_omap.end(); i++) { - Offset* o = m_omap.GetNextValue(pos); + Offset* o = (*i).second; for(int i = 0; i < countof(o->col); i++) { @@ -479,16 +477,10 @@ GSLocalMemory::~GSLocalMemory() _aligned_free(o); } - m_omap.RemoveAll(); - - pos = m_o4map.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_o4map.begin(); i != m_o4map.end(); i++) { - _aligned_free(m_o4map.GetNextValue(pos)); + _aligned_free((*i).second); } - - m_o4map.RemoveAll(); } GSLocalMemory::Offset* GSLocalMemory::GetOffset(DWORD bp, DWORD bw, DWORD psm) @@ -499,9 +491,11 @@ GSLocalMemory::Offset* GSLocalMemory::GetOffset(DWORD bp, DWORD bw, DWORD psm) DWORD hash = bp | (bw << 14) | (psm << 20); - if(CRBMap::CPair* pair = m_omap.Lookup(hash)) + hash_map::iterator i = m_omap.find(hash); + + if(i != m_omap.end()) { - return pair->m_value; + return (*i).second; } Offset* o = (Offset*)_aligned_malloc(sizeof(Offset), 16); @@ -524,7 +518,7 @@ GSLocalMemory::Offset* GSLocalMemory::GetOffset(DWORD bp, DWORD bw, DWORD psm) memcpy(o->col[i], m_psm[psm].rowOffset[0], sizeof(int) * 2048); } - m_omap.SetAt(hash, o); + m_omap[hash] = o; return o; } @@ -546,9 +540,11 @@ GSLocalMemory::Offset4* GSLocalMemory::GetOffset4(const GIFRegFRAME& FRAME, cons DWORD hash = (FRAME.FBP << 0) | (ZBUF.ZBP << 9) | (bw << 18) | (fpsm_hash << 24) | (zpsm_hash << 28); - if(CRBMap::CPair* pair = m_o4map.Lookup(hash)) + hash_map::iterator i = m_o4map.find(hash); + + if(i != m_o4map.end()) { - return pair->m_value; + return (*i).second; } Offset4* o = (Offset4*)_aligned_malloc(sizeof(Offset4), 16); @@ -573,7 +569,7 @@ GSLocalMemory::Offset4* GSLocalMemory::GetOffset4(const GIFRegFRAME& FRAME, cons o->col[i].y = m_psm[zpsm].rowOffset[0][i * 4] << zs; } - m_o4map.SetAt(hash, o); + m_o4map[hash] = o; return o; } @@ -2543,7 +2539,7 @@ if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n"); } } -HRESULT GSLocalMemory::SaveBMP(LPCTSTR fn, DWORD bp, DWORD bw, DWORD psm, int w, int h) +HRESULT GSLocalMemory::SaveBMP(const string& fn, DWORD bp, DWORD bw, DWORD psm, int w, int h) { int pitch = w * 4; int size = pitch * h; @@ -2571,7 +2567,7 @@ HRESULT GSLocalMemory::SaveBMP(LPCTSTR fn, DWORD bp, DWORD bw, DWORD psm, int w, for(int i = 0; i < w; i++) ((DWORD*)p)[i] = (this->*rp)(i, j, TEX0.TBP0, TEX0.TBW); - if(FILE* fp = _tfopen(fn, _T("wb"))) + if(FILE* fp = fopen(fn.c_str(), "wb")) { BITMAPINFOHEADER bih; memset(&bih, 0, sizeof(bih)); diff --git a/plugins/GSdx/GSLocalMemory.h b/plugins/GSdx/GSLocalMemory.h index b5063cb087..fadd7ecee0 100644 --- a/plugins/GSdx/GSLocalMemory.h +++ b/plugins/GSdx/GSLocalMemory.h @@ -141,8 +141,8 @@ protected: // - CRBMapC m_omap; - CRBMapC m_o4map; + hash_map m_omap; + hash_map m_o4map; public: GSLocalMemory(); @@ -993,7 +993,7 @@ public: // - HRESULT SaveBMP(LPCTSTR fn, DWORD bp, DWORD bw, DWORD psm, int w, int h); + HRESULT SaveBMP(const string& fn, DWORD bp, DWORD bw, DWORD psm, int w, int h); }; #pragma warning(default: 4244) \ No newline at end of file diff --git a/plugins/GSdx/GSPerfMon.cpp b/plugins/GSdx/GSPerfMon.cpp index ba3aa1a809..3a5f2d297e 100644 --- a/plugins/GSdx/GSPerfMon.cpp +++ b/plugins/GSdx/GSPerfMon.cpp @@ -33,7 +33,6 @@ GSPerfMon::GSPerfMon() { memset(m_counters, 0, sizeof(m_counters)); memset(m_stats, 0, sizeof(m_stats)); - memset(m_warnings, 0, sizeof(m_warnings)); } void GSPerfMon::Put(counter_t c, double val) diff --git a/plugins/GSdx/GSPerfMon.h b/plugins/GSdx/GSPerfMon.h index 1c9b94921d..42463551c5 100644 --- a/plugins/GSdx/GSPerfMon.h +++ b/plugins/GSdx/GSPerfMon.h @@ -25,12 +25,10 @@ class GSPerfMon { public: enum counter_t {Frame, Prim, Draw, Swizzle, Unswizzle, Fillrate, Quad, CounterLast}; - enum warning_t {DATE, PABE, ABE, COLCLAMP, DepthTexture, WarningLast}; protected: double m_counters[CounterLast]; double m_stats[CounterLast]; - bool m_warnings[WarningLast]; UINT64 m_begin, m_total, m_start, m_frame; clock_t m_lastframe; int m_count; @@ -47,8 +45,6 @@ public: UINT64 GetFrame() {return m_frame;} void Put(counter_t c, double val = 0); double Get(counter_t c) {return m_stats[c];} - void Put(warning_t c) {m_warnings[c] = true;} - bool Get(warning_t c) {bool b = m_warnings[c]; m_warnings[c] = false; return b;} void Update(); int CPU(); }; diff --git a/plugins/GSdx/GSRasterizer.cpp b/plugins/GSdx/GSRasterizer.cpp index 053e789084..17795fd9c5 100644 --- a/plugins/GSdx/GSRasterizer.cpp +++ b/plugins/GSdx/GSRasterizer.cpp @@ -922,10 +922,12 @@ GSRasterizerList::~GSRasterizerList() void GSRasterizerList::FreeRasterizers() { - while(!IsEmpty()) + for(list::iterator i = begin(); i != end(); i++) { - delete RemoveHead(); + delete *i; } + + clear(); } void GSRasterizerList::Draw(const GSRasterizerData* data) @@ -936,11 +938,9 @@ void GSRasterizerList::Draw(const GSRasterizerData* data) __int64 start = __rdtsc(); - POSITION pos = GetTailPosition(); - - while(pos) + for(list::reverse_iterator i = rbegin(); i != rend(); i++) { - GetPrev(pos)->Draw(data); + (*i)->Draw(data); } while(*m_sync) @@ -950,13 +950,11 @@ void GSRasterizerList::Draw(const GSRasterizerData* data) m_stats.ticks = __rdtsc() - start; - pos = GetHeadPosition(); - - while(pos) + for(list::iterator i = begin(); i != end(); i++) { GSRasterizerStats s; - GetNext(pos)->GetStats(s); + (*i)->GetStats(s); m_stats.pixels += s.pixels; m_stats.prims = max(m_stats.prims, s.prims); @@ -970,8 +968,8 @@ void GSRasterizerList::GetStats(GSRasterizerStats& stats) void GSRasterizerList::PrintStats() { - if(!IsEmpty()) + if(!empty()) { - GetHead()->PrintStats(); + front()->PrintStats(); } } diff --git a/plugins/GSdx/GSRasterizer.h b/plugins/GSdx/GSRasterizer.h index 0f24c794f2..651899b91a 100644 --- a/plugins/GSdx/GSRasterizer.h +++ b/plugins/GSdx/GSRasterizer.h @@ -123,7 +123,7 @@ public: void Draw(const GSRasterizerData* data); }; -class GSRasterizerList : protected CAtlList, public IRasterizer +class GSRasterizerList : protected list, public IRasterizer { long* m_sync; GSRasterizerStats m_stats; @@ -142,7 +142,7 @@ public: for(int i = 0; i < threads; i++) { - AddTail(new GSRasterizerMT(new DS(parent, i), i, threads, m_sync)); + push_back(new GSRasterizerMT(new DS(parent, i), i, threads, m_sync)); } } diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index 56bd999fb7..e25a0fe6f4 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -108,9 +108,9 @@ public: m_blur = rs.m_blur; }; - virtual bool Create(LPCTSTR title) = 0; + virtual bool Create(const string& title) = 0; virtual void VSync(int field) = 0; - virtual bool MakeSnapshot(LPCTSTR path) = 0; + virtual bool MakeSnapshot(const string& path) = 0; }; template class GSRenderer : public GSRendererBase @@ -323,7 +323,7 @@ protected: void DoSnapshot(int field) { - if(!m_snapshot.IsEmpty()) + if(!m_snapshot.empty()) { if(!m_dump && (::GetAsyncKeyState(VK_SHIFT) & 0x8000)) { @@ -339,9 +339,9 @@ protected: delete [] fd.data; } - m_dev.SaveCurrent(m_snapshot + _T(".bmp")); + m_dev.SaveCurrent(m_snapshot + ".bmp"); - m_snapshot.Empty(); + m_snapshot.clear(); } else { @@ -408,7 +408,7 @@ public: bool s_save; bool s_savez; - CString m_snapshot; + string m_snapshot; GSCapture m_capture; public: @@ -422,9 +422,9 @@ public: s_savez = !!AfxGetApp()->GetProfileInt(_T("Debug"), _T("savez"), 0); } - bool Create(LPCTSTR title) + bool Create(const string& title) { - if(!m_wnd.Create(title)) + if(!m_wnd.Create(title.c_str())) { return false; } @@ -456,7 +456,7 @@ public: // osd static UINT64 s_frame = 0; - static CString s_stats; + static string s_stats; if(m_perfmon.GetFrame() - s_frame >= 30) { @@ -465,11 +465,13 @@ public: s_frame = m_perfmon.GetFrame(); double fps = 1000.0f / m_perfmon.Get(GSPerfMon::Frame); + + string interlace = m_regs->SMODE2.INT ? (string("Interlaced ") + (m_regs->SMODE2.FFMD ? "(frame)" : "(field)")) : "Progressive"; - s_stats.Format( - _T("%I64d | %d x %d | %.2f fps (%d%%) | %s - %s | %s | %d/%d/%d | %d%% CPU | %.2f | %.2f"), + s_stats = format( + "%I64d | %d x %d | %.2f fps (%d%%) | %s - %s | %s | %d/%d/%d | %d%% CPU | %.2f | %.2f", m_perfmon.GetFrame(), GetDisplaySize().cx, GetDisplaySize().cy, fps, (int)(100.0 * fps / GetFPS()), - m_regs->SMODE2.INT ? (CString(_T("Interlaced ")) + (m_regs->SMODE2.FFMD ? _T("(frame)") : _T("(field)"))) : _T("Progressive"), + interlace.c_str(), GSSettingsDlg::g_interlace[m_interlace].name, GSSettingsDlg::g_aspectratio[m_aspectratio].name, (int)m_perfmon.Get(GSPerfMon::Quad), @@ -484,26 +486,20 @@ public: if(fillrate > 0) { - s_stats.Format(_T("%s | %.2f mpps"), CString(s_stats), fps * fillrate / (1024 * 1024)); + s_stats += format(" | %.2f mpps", fps * fillrate / (1024 * 1024)); } if(m_capture.IsCapturing()) { - s_stats += _T(" | Recording..."); + s_stats += " | Recording..."; } - if(m_perfmon.Get(GSPerfMon::COLCLAMP)) _tprintf(_T("*** NOT SUPPORTED: color wrap ***\n")); - if(m_perfmon.Get(GSPerfMon::PABE)) _tprintf(_T("*** NOT SUPPORTED: per pixel alpha blend ***\n")); - if(m_perfmon.Get(GSPerfMon::DATE)) _tprintf(_T("*** PERFORMANCE WARNING: destination alpha test used ***\n")); - if(m_perfmon.Get(GSPerfMon::ABE)) _tprintf(_T("*** NOT SUPPORTED: alpha blending mode ***\n")); - if(m_perfmon.Get(GSPerfMon::DepthTexture)) _tprintf(_T("*** NOT SUPPORTED: depth texture ***\n")); - - m_wnd.SetWindowText(s_stats); + m_wnd.SetWindowText(s_stats.c_str()); } if(m_osd) { - m_dev.Draw(s_stats + _T("\n\nF5: interlace mode\nF6: aspect ratio\nF7: OSD")); + m_dev.Draw(s_stats + "\n\nF5: interlace mode\nF6: aspect ratio\nF7: OSD"); } if(m_frameskip) @@ -535,11 +531,11 @@ public: DoCapture(); } - bool MakeSnapshot(LPCTSTR path) + bool MakeSnapshot(const string& path) { - if(m_snapshot.IsEmpty()) + if(m_snapshot.empty()) { - m_snapshot.Format(_T("%s_%s"), path, CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S"))); + m_snapshot = format("%s_%s", path.c_str(), CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S"))); } return true; diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index e0d1818d25..1fb8a3b597 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -261,9 +261,12 @@ protected: if(s_dump) { - CString str; - str.Format(_T("c:\\temp2\\_%05d_f%I64d_fr%d_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM); - if(s_save) rt->m_texture.Save(str); + if(s_save) + { + rt->m_texture.Save(format("c:\\temp2\\_%05d_f%I64d_fr%d_%05x_%d.bmp", s_n, m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM)); + } + + s_n++; } return true; @@ -321,19 +324,45 @@ protected: if(s_dump) { - CString str; - str.Format(_T("c:\\temp2\\_%05d_f%I64d_tex_%05x_%d_%d%d_%02x_%02x_%02x_%02x.dds"), - s_n++, m_perfmon.GetFrame(), (int)context->TEX0.TBP0, (int)context->TEX0.PSM, - (int)context->CLAMP.WMS, (int)context->CLAMP.WMT, - (int)context->CLAMP.MINU, (int)context->CLAMP.MAXU, - (int)context->CLAMP.MINV, (int)context->CLAMP.MAXV); - if(PRIM->TME) if(s_save) tex->m_texture.Save(str, true); - str.Format(_T("c:\\temp2\\_%05d_f%I64d_tpx_%05x_%d.dds"), s_n-1, m_perfmon.GetFrame(), context->TEX0.CBP, context->TEX0.CPSM); - if(PRIM->TME && tex->m_palette) if(s_save) tex->m_palette.Save(str, true); - str.Format(_T("c:\\temp2\\_%05d_f%I64d_rt0_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), context->FRAME.Block(), context->FRAME.PSM); - if(s_save) rt->m_texture.Save(str); - str.Format(_T("c:\\temp2\\_%05d_f%I64d_rz0_%05x_%d.bmp"), s_n-1, m_perfmon.GetFrame(), context->ZBUF.Block(), context->ZBUF.PSM); - if(s_savez) ds->m_texture.Save(str); + UINT64 frame = m_perfmon.GetFrame(); + + string s; + + if(s_save && PRIM->TME) + { + s = format("c:\\temp2\\_%05d_f%I64d_tex_%05x_%d_%d%d_%02x_%02x_%02x_%02x.dds", + s_n, frame, (int)context->TEX0.TBP0, (int)context->TEX0.PSM, + (int)context->CLAMP.WMS, (int)context->CLAMP.WMT, + (int)context->CLAMP.MINU, (int)context->CLAMP.MAXU, + (int)context->CLAMP.MINV, (int)context->CLAMP.MAXV); + + tex->m_texture.Save(s, true); + + if(tex->m_palette) + { + s = format("c:\\temp2\\_%05d_f%I64d_tpx_%05x_%d.dds", s_n, frame, context->TEX0.CBP, context->TEX0.CPSM); + + tex->m_palette.Save(s, true); + } + } + + s_n++; + + if(s_save) + { + s = format("c:\\temp2\\_%05d_f%I64d_rt0_%05x_%d.bmp", s_n, frame, context->FRAME.Block(), context->FRAME.PSM); + + rt->m_texture.Save(s); + } + + if(s_savez) + { + s = format("c:\\temp2\\_%05d_f%I64d_rz0_%05x_%d.bmp", s_n, frame, context->ZBUF.Block(), context->ZBUF.PSM); + + ds->m_texture.Save(s); + } + + s_n++; } int prim = PRIM->PRIM; @@ -349,12 +378,25 @@ protected: if(s_dump) { - CString str; - str.Format(_T("c:\\temp2\\_%05d_f%I64d_rt1_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), context->FRAME.Block(), context->FRAME.PSM); - if(s_save) rt->m_texture.Save(str); - str.Format(_T("c:\\temp2\\_%05d_f%I64d_rz1_%05x_%d.bmp"), s_n-1, m_perfmon.GetFrame(), context->ZBUF.Block(), context->ZBUF.PSM); - if(s_savez) ds->m_texture.Save(str); - // if(s_savez) m_dev.SaveToFileD32S8X24(ds->m_texture, str); // TODO + UINT64 frame = m_perfmon.GetFrame(); + + string s; + + if(s_save) + { + s = format("c:\\temp2\\_%05d_f%I64d_rt1_%05x_%d.bmp", s_n, frame, context->FRAME.Block(), context->FRAME.PSM); + + rt->m_texture.Save(s); + } + + if(s_savez) + { + s = format("c:\\temp2\\_%05d_f%I64d_rz1_%05x_%d.bmp", s_n, frame, context->ZBUF.Block(), context->ZBUF.PSM); + + ds->m_texture.Save(s); + } + + s_n++; } m_tc->InvalidateTextures(context->FRAME, context->ZBUF); diff --git a/plugins/GSdx/GSRendererHW10.cpp b/plugins/GSdx/GSRendererHW10.cpp index 0265f582d8..4069eb711c 100644 --- a/plugins/GSdx/GSRendererHW10.cpp +++ b/plugins/GSdx/GSRendererHW10.cpp @@ -30,7 +30,7 @@ GSRendererHW10::GSRendererHW10(BYTE* base, bool mt, void (*irq)(), const GSRende InitVertexKick(); } -bool GSRendererHW10::Create(LPCTSTR title) +bool GSRendererHW10::Create(const string& title) { if(!__super::Create(title)) return false; diff --git a/plugins/GSdx/GSRendererHW10.h b/plugins/GSdx/GSRendererHW10.h index a9985dfc0f..23a1dbfadf 100644 --- a/plugins/GSdx/GSRendererHW10.h +++ b/plugins/GSdx/GSRendererHW10.h @@ -50,7 +50,7 @@ protected: public: GSRendererHW10(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs); - bool Create(LPCTSTR title); + bool Create(const string& title); template void VertexKick(bool skip); }; \ No newline at end of file diff --git a/plugins/GSdx/GSRendererHW9.cpp b/plugins/GSdx/GSRendererHW9.cpp index 47acb327a3..48bff43558 100644 --- a/plugins/GSdx/GSRendererHW9.cpp +++ b/plugins/GSdx/GSRendererHW9.cpp @@ -33,7 +33,7 @@ GSRendererHW9::GSRendererHW9(BYTE* base, bool mt, void (*irq)(), const GSRendere InitVertexKick(); } -bool GSRendererHW9::Create(LPCTSTR title) +bool GSRendererHW9::Create(const string& title) { if(!__super::Create(title)) return false; diff --git a/plugins/GSdx/GSRendererHW9.h b/plugins/GSdx/GSRendererHW9.h index c91a0cb42d..073e0c552e 100644 --- a/plugins/GSdx/GSRendererHW9.h +++ b/plugins/GSdx/GSRendererHW9.h @@ -59,7 +59,7 @@ protected: public: GSRendererHW9(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs); - bool Create(LPCTSTR title); + bool Create(const string& title); template void VertexKick(bool skip); }; diff --git a/plugins/GSdx/GSRendererSW.h b/plugins/GSdx/GSRendererSW.h index 2f540cacc6..86de0df48f 100644 --- a/plugins/GSdx/GSRendererSW.h +++ b/plugins/GSdx/GSRendererSW.h @@ -109,9 +109,12 @@ protected: if(s_dump) { - CString str; - str.Format(_T("c:\\temp1\\_%05d_f%I64d_fr%d_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM); - if(s_save) t.Save(str); + if(s_save) + { + t.Save(format("c:\\temp1\\_%05d_f%I64d_fr%d_%05x_%d.bmp", s_n, m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM)); + } + + s_n++; } return true; @@ -550,13 +553,34 @@ protected: if(s_dump) { - CString str; - str.Format(_T("c:\\temp1\\_%05d_f%I64d_tex_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), (int)m_context->TEX0.TBP0, (int)m_context->TEX0.PSM); - if(PRIM->TME) if(s_save) {m_mem.SaveBMP(str, m_context->TEX0.TBP0, m_context->TEX0.TBW, m_context->TEX0.PSM, 1 << m_context->TEX0.TW, 1 << m_context->TEX0.TH);} - str.Format(_T("c:\\temp1\\_%05d_f%I64d_rt0_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), m_context->FRAME.Block(), m_context->FRAME.PSM); - if(s_save) {m_mem.SaveBMP(str, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameSize().cx, 512);}//GetFrameSize(1).cy); - str.Format(_T("c:\\temp1\\_%05d_f%I64d_rz0_%05x_%d.bmp"), s_n-1, m_perfmon.GetFrame(), m_context->ZBUF.Block(), m_context->ZBUF.PSM); - if(s_savez) {m_mem.SaveBMP(str, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameSize().cx, 512);} + UINT64 frame = m_perfmon.GetFrame(); + + string s; + + if(s_save && PRIM->TME) + { + s = format("c:\\temp1\\_%05d_f%I64d_tex_%05x_%d.bmp", s_n, frame, (int)m_context->TEX0.TBP0, (int)m_context->TEX0.PSM); + + m_mem.SaveBMP(s, m_context->TEX0.TBP0, m_context->TEX0.TBW, m_context->TEX0.PSM, 1 << m_context->TEX0.TW, 1 << m_context->TEX0.TH); + } + + s_n++; + + if(s_save) + { + s = format("c:\\temp1\\_%05d_f%I64d_rt0_%05x_%d.bmp", s_n, frame, m_context->FRAME.Block(), m_context->FRAME.PSM); + + m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameSize().cx, 512);//GetFrameSize(1).cy); + } + + if(s_savez) + { + s = format("c:\\temp1\\_%05d_f%I64d_rz0_%05x_%d.bmp", s_n, frame, m_context->ZBUF.Block(), m_context->ZBUF.PSM); + + m_mem.SaveBMP(s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameSize().cx, 512); + } + + s_n++; } GSRasterizerData data; @@ -611,11 +635,25 @@ protected: if(s_dump) { - CString str; - str.Format(_T("c:\\temp1\\_%05d_f%I64d_rt1_%05x_%d.bmp"), s_n++, m_perfmon.GetFrame(), m_context->FRAME.Block(), m_context->FRAME.PSM); - if(s_save) {m_mem.SaveBMP(str, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameSize().cx, 512);}//GetFrameSize(1).cy); - str.Format(_T("c:\\temp1\\_%05d_f%I64d_rz1_%05x_%d.bmp"), s_n-1, m_perfmon.GetFrame(), m_context->ZBUF.Block(), m_context->ZBUF.PSM); - if(s_savez) {m_mem.SaveBMP(str, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameSize().cx, 512);} + UINT64 frame = m_perfmon.GetFrame(); + + string s; + + if(s_save) + { + s = format("c:\\temp1\\_%05d_f%I64d_rt1_%05x_%d.bmp", s_n, frame, m_context->FRAME.Block(), m_context->FRAME.PSM); + + m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameSize().cx, 512);//GetFrameSize(1).cy); + } + + if(s_savez) + { + s = format("c:\\temp1\\_%05d_f%I64d_rz1_%05x_%d.bmp", s_n, frame, m_context->ZBUF.Block(), m_context->ZBUF.PSM); + + m_mem.SaveBMP(s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameSize().cx, 512); + } + + s_n++; } if(0)//stats.ticks > 5000000) diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 333744a560..133cc864d6 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -147,17 +147,17 @@ BOOL GSSettingsDlg::OnInitDialog() memset(&caps, 0, sizeof(caps)); caps.PixelShaderVersion = D3DPS_VERSION(0, 0); - m_modes.RemoveAll(); + m_modes.clear(); // windowed { D3DDISPLAYMODE mode; memset(&mode, 0, sizeof(mode)); - m_modes.AddTail(mode); + m_modes.push_back(mode); int iItem = m_resolution.AddString(_T("Windowed")); - m_resolution.SetItemDataPtr(iItem, m_modes.GetTailPosition()); + m_resolution.SetItemDataPtr(iItem, &m_modes.back()); m_resolution.SetCurSel(iItem); } @@ -177,12 +177,11 @@ BOOL GSSettingsDlg::OnInitDialog() if(S_OK == d3d->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i, &mode)) { - CString str; - str.Format(_T("%dx%d %dHz"), mode.Width, mode.Height, mode.RefreshRate); - int iItem = m_resolution.AddString(str); + string str = format("%dx%d %dHz", mode.Width, mode.Height, mode.RefreshRate); + int iItem = m_resolution.AddString(str.c_str()); - m_modes.AddTail(mode); - m_resolution.SetItemDataPtr(iItem, m_modes.GetTailPosition()); + m_modes.push_back(mode); + m_resolution.SetItemDataPtr(iItem, &m_modes.back()); if(ModeWidth == mode.Width && ModeHeight == mode.Height && ModeRefreshRate == mode.RefreshRate) { @@ -196,16 +195,16 @@ BOOL GSSettingsDlg::OnInitDialog() bool isdx10avail = GSUtil::IsDirect3D10Available(); - CAtlArray renderers; + vector renderers; for(size_t i = 0; i < countof(g_renderers); i++) { if(i >= 3 && i <= 5 && !isdx10avail) continue; - renderers.Add(g_renderers[i]); + renderers.push_back(g_renderers[i]); } - GSSetting::InitComboBox(renderers.GetData(), renderers.GetCount(), m_renderer, pApp->GetProfileInt(_T("Settings"), _T("Renderer"), 0)); + GSSetting::InitComboBox(&renderers[0], renderers.size(), m_renderer, pApp->GetProfileInt(_T("Settings"), _T("Renderer"), 0)); GSSetting::InitComboBox(g_psversion, countof(g_psversion), m_psversion, pApp->GetProfileInt(_T("Settings"), _T("PixelShaderVersion2"), D3DPS_VERSION(2, 0)), caps.PixelShaderVersion); GSSetting::InitComboBox(g_interlace, countof(g_interlace), m_interlace, pApp->GetProfileInt(_T("Settings"), _T("Interlace"), 0)); GSSetting::InitComboBox(g_aspectratio, countof(g_aspectratio), m_aspectratio, pApp->GetProfileInt(_T("Settings"), _T("AspectRatio"), 1)); @@ -251,7 +250,8 @@ void GSSettingsDlg::OnOK() if(m_resolution.GetCurSel() >= 0) { - D3DDISPLAYMODE& mode = m_modes.GetAt((POSITION)m_resolution.GetItemData(m_resolution.GetCurSel())); + D3DDISPLAYMODE& mode = *(D3DDISPLAYMODE*)m_resolution.GetItemData(m_resolution.GetCurSel()); + pApp->WriteProfileInt(_T("Settings"), _T("ModeWidth"), mode.Width); pApp->WriteProfileInt(_T("Settings"), _T("ModeHeight"), mode.Height); pApp->WriteProfileInt(_T("Settings"), _T("ModeRefreshRate"), mode.RefreshRate); diff --git a/plugins/GSdx/GSSettingsDlg.h b/plugins/GSdx/GSSettingsDlg.h index e2b68c41bf..1f48ce710d 100644 --- a/plugins/GSdx/GSSettingsDlg.h +++ b/plugins/GSdx/GSSettingsDlg.h @@ -29,7 +29,7 @@ class GSSettingsDlg : public CDialog DECLARE_DYNAMIC(GSSettingsDlg) private: - CAtlList m_modes; + list m_modes; public: GSSettingsDlg(CWnd* pParent = NULL); // standard constructor diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 81bba7ec3d..10aa63ff4d 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -1000,11 +1000,11 @@ void GSState::FlushWrite() InvalidateVideoMem(m_env.BITBLTBUF, r); /* static int n = 0; - CString str; - str.Format(_T("c:\\temp1\\[%04d]_%05x_%d_%d_%d_%d_%d_%d.bmp"), + string s; + s = format("c:\\temp1\\[%04d]_%05x_%d_%d_%d_%d_%d_%d.bmp", n++, (int)m_env.BITBLTBUF.DBP, (int)m_env.BITBLTBUF.DBW, (int)m_env.BITBLTBUF.DPSM, r.left, r.top, r.right, r.bottom); - m_mem.SaveBMP(str, m_env.BITBLTBUF.DBP, m_env.BITBLTBUF.DBW, m_env.BITBLTBUF.DPSM, r.right, r.bottom); + m_mem.SaveBMP(s, m_env.BITBLTBUF.DBP, m_env.BITBLTBUF.DBW, m_env.BITBLTBUF.DPSM, r.right, r.bottom); */ } @@ -1275,6 +1275,7 @@ template void GSState::Transfer(BYTE* mem, UINT32 size) break; case GIF_FLG_IMAGE: + { int len = (int)min(size, path.nloop); diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index fbf204ada8..39d8af3a27 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -42,7 +42,7 @@ public: virtual bool Update(const CRect& r, const void* data, int pitch) = 0; virtual bool Map(BYTE** bits, int& pitch, const RECT* r = NULL) = 0; virtual void Unmap() = 0; - virtual bool Save(CString fn, bool dds = false) = 0; + virtual bool Save(const string& fn, bool dds = false) = 0; CSize GetSize() {return CSize(GetWidth(), GetHeight());} }; diff --git a/plugins/GSdx/GSTexture10.cpp b/plugins/GSdx/GSTexture10.cpp index 615e8c25bc..4b14de0539 100644 --- a/plugins/GSdx/GSTexture10.cpp +++ b/plugins/GSdx/GSTexture10.cpp @@ -109,7 +109,7 @@ void GSTexture10::Unmap() } } -bool GSTexture10::Save(CString fn, bool dds) +bool GSTexture10::Save(const string& fn, bool dds) { CComPtr res; @@ -164,7 +164,7 @@ bool GSTexture10::Save(CString fn, bool dds) res = m_texture; } - return SUCCEEDED(D3DX10SaveTextureToFile(res, dds ? D3DX10_IFF_DDS : D3DX10_IFF_BMP, fn)); + return SUCCEEDED(D3DX10SaveTextureToFile(res, dds ? D3DX10_IFF_DDS : D3DX10_IFF_BMP, fn.c_str())); } ID3D10Texture2D* GSTexture10::operator->() diff --git a/plugins/GSdx/GSTexture10.h b/plugins/GSdx/GSTexture10.h index 9c1eb30964..3609224696 100644 --- a/plugins/GSdx/GSTexture10.h +++ b/plugins/GSdx/GSTexture10.h @@ -46,7 +46,7 @@ public: bool Update(const CRect& r, const void* data, int pitch); bool Map(BYTE** bits, int& pitch, const RECT* r = NULL); void Unmap(); - bool Save(CString fn, bool dds = false); + bool Save(const string& fn, bool dds = false); ID3D10Texture2D* operator->(); // TODO: remove direct access diff --git a/plugins/GSdx/GSTexture7.cpp b/plugins/GSdx/GSTexture7.cpp index e69406e928..c817e2130d 100644 --- a/plugins/GSdx/GSTexture7.cpp +++ b/plugins/GSdx/GSTexture7.cpp @@ -166,7 +166,7 @@ void GSTexture7::Unmap() } } -bool GSTexture7::Save(CString fn, bool dds) +bool GSTexture7::Save(const string& fn, bool dds) { // TODO diff --git a/plugins/GSdx/GSTexture7.h b/plugins/GSdx/GSTexture7.h index 62eef7ea28..b2bdc0656a 100644 --- a/plugins/GSdx/GSTexture7.h +++ b/plugins/GSdx/GSTexture7.h @@ -47,7 +47,7 @@ public: bool Update(const CRect& r, const void* data, int pitch); bool Map(BYTE** bits, int& pitch, const RECT* r = NULL); void Unmap(); - bool Save(CString fn, bool dds = false); + bool Save(const string& fn, bool dds = false); IDirectDrawSurface7* operator->(); // TODO: remove direct access diff --git a/plugins/GSdx/GSTexture9.cpp b/plugins/GSdx/GSTexture9.cpp index bff9df141c..b12fc2f684 100644 --- a/plugins/GSdx/GSTexture9.cpp +++ b/plugins/GSdx/GSTexture9.cpp @@ -138,7 +138,7 @@ void GSTexture9::Unmap() } } -bool GSTexture9::Save(CString fn, bool dds) +bool GSTexture9::Save(const string& fn, bool dds) { CComPtr surface; @@ -181,12 +181,12 @@ bool GSTexture9::Save(CString fn, bool dds) if(surface != NULL) { - return SUCCEEDED(D3DXSaveSurfaceToFile(fn, dds ? D3DXIFF_DDS : D3DXIFF_BMP, surface, NULL, NULL)); + return SUCCEEDED(D3DXSaveSurfaceToFile(fn.c_str(), dds ? D3DXIFF_DDS : D3DXIFF_BMP, surface, NULL, NULL)); } /* if(CComQIPtr texture = surface) { - return SUCCEEDED(D3DXSaveTextureToFile(fn, dds ? D3DXIFF_DDS : D3DXIFF_BMP, texture, NULL)); + return SUCCEEDED(D3DXSaveTextureToFile(fn.c_str(), dds ? D3DXIFF_DDS : D3DXIFF_BMP, texture, NULL)); } */ return false; diff --git a/plugins/GSdx/GSTexture9.h b/plugins/GSdx/GSTexture9.h index c952cda68e..fe46918e34 100644 --- a/plugins/GSdx/GSTexture9.h +++ b/plugins/GSdx/GSTexture9.h @@ -45,7 +45,7 @@ public: bool Update(const CRect& r, const void* data, int pitch); bool Map(BYTE** bits, int& pitch, const RECT* r = NULL); void Unmap(); - bool Save(CString fn, bool dds = false); + bool Save(const string& fn, bool dds = false); IDirect3DTexture9* operator->(); // TODO: remove direct access diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index bc84dad34c..6168bc88a4 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -114,11 +114,9 @@ public: CRect r(0, 0, w, h); - POSITION pos = m_dirty.GetHeadPosition(); - - while(pos) + for(list::iterator i = m_dirty.begin(); i != m_dirty.end(); i++) { - const CRect& dirty = m_dirty.GetNext(pos).GetDirtyRect(m_TEX0) & r; + const CRect& dirty = i->GetDirtyRect(m_TEX0) & r; if(!(m_valid & dirty).IsRectEmpty()) { @@ -145,7 +143,7 @@ public: } } - m_dirty.RemoveAll(); + m_dirty.clear(); m_renderer->MinMaxUV(w, h, r); @@ -214,23 +212,21 @@ public: protected: GSRenderer* m_renderer; - CAtlList m_rt; - CAtlList m_ds; - CAtlList m_tex; + list m_rt; + list m_ds; + list m_tex; - template void RecycleByAge(CAtlList& l, int maxage = 60) + template void RecycleByAge(list& l, int maxage = 60) { - POSITION pos = l.GetHeadPosition(); - - while(pos) + for(list::iterator i = l.begin(); i != l.end(); ) { - POSITION cur = pos; + list::iterator j = i++; - T* t = l.GetNext(pos); + T* t = *j; if(++t->m_age > maxage) { - l.RemoveAt(cur); + l.erase(j); delete t; } @@ -254,9 +250,26 @@ public: void RemoveAll() { - while(m_rt.GetCount()) delete m_rt.RemoveHead(); - while(m_ds.GetCount()) delete m_ds.RemoveHead(); - while(m_tex.GetCount()) delete m_tex.RemoveHead(); + for(list::iterator i = m_rt.begin(); i != m_rt.end(); i++) + { + delete *i; + } + + m_rt.clear(); + + for(list::iterator i = m_ds.begin(); i != m_ds.end(); i++) + { + delete *i; + } + + m_ds.clear(); + + for(list::iterator i = m_tex.begin(); i != m_tex.end(); i++) + { + delete *i; + } + + m_tex.clear(); } GSRenderTarget* GetRenderTarget(const GIFRegTEX0& TEX0, int w, int h, bool fb = false) @@ -265,13 +278,13 @@ public: if(rt == NULL) { - for(POSITION pos = m_rt.GetHeadPosition(); pos; m_rt.GetNext(pos)) + for(list::iterator i = m_rt.begin(); i != m_rt.end(); i++) { - GSRenderTarget* rt2 = m_rt.GetAt(pos); + GSRenderTarget* rt2 = *i; if(rt2->m_TEX0.TBP0 == TEX0.TBP0) { - m_rt.MoveToHead(pos); + m_rt.splice(m_rt.begin(), m_rt, i); rt = rt2; @@ -288,9 +301,9 @@ public: { // HACK: try to find something close to the base pointer - for(POSITION pos = m_rt.GetHeadPosition(); pos; m_rt.GetNext(pos)) + for(list::iterator i = m_rt.begin(); i != m_rt.end(); i++) { - GSRenderTarget* rt2 = m_rt.GetAt(pos); + GSRenderTarget* rt2 = *i; if(rt2->m_TEX0.TBP0 <= TEX0.TBP0 && TEX0.TBP0 < rt2->m_TEX0.TBP0 + 0x700 && (!rt || rt2->m_TEX0.TBP0 >= rt->m_TEX0.TBP0)) { @@ -317,7 +330,7 @@ public: return NULL; } - m_rt.AddHead(rt); + m_rt.push_front(rt); } if(m_renderer->CanUpscale()) @@ -351,13 +364,13 @@ public: if(ds == NULL) { - for(POSITION pos = m_ds.GetHeadPosition(); pos; m_ds.GetNext(pos)) + for(list::iterator i = m_ds.begin(); i != m_ds.end(); i++) { - GSDepthStencil* ds2 = m_ds.GetAt(pos); + GSDepthStencil* ds2 = *i; if(ds2->m_TEX0.TBP0 == TEX0.TBP0) { - m_ds.MoveToHead(pos); + m_ds.splice(m_ds.begin(), m_ds, i); ds = ds2; @@ -383,7 +396,7 @@ public: return NULL; } - m_ds.AddHead(ds); + m_ds.push_front(ds); } if(m_renderer->m_context->DepthWrite()) @@ -459,9 +472,9 @@ public: GSTexture* t = NULL; - for(POSITION pos = m_tex.GetHeadPosition(); pos; m_tex.GetNext(pos)) + for(list::iterator i = m_tex.begin(); i != m_tex.end(); i++) { - t = m_tex.GetAt(pos); + t = *i; if(GSUtil::HasSharedBits(t->m_TEX0.TBP0, t->m_TEX0.PSM, TEX0.TBP0, TEX0.PSM)) { @@ -470,7 +483,7 @@ public: && (m_renderer->m_psrr || (CLAMP.WMS != 3 && t->m_CLAMP.WMS != 3 && CLAMP.WMT != 3 && t->m_CLAMP.WMT != 3 || CLAMP.i64 == t->m_CLAMP.i64)) && (pal == 0 || TEX0.CPSM == t->m_TEX0.CPSM && GSVector4i::compare(t->m_clut, clut, pal * sizeof(clut[0])))) { - m_tex.MoveToHead(pos); + m_tex.splice(m_tex.begin(), m_tex, i); break; } @@ -481,11 +494,11 @@ public: if(t == NULL) { - for(POSITION pos = m_rt.GetHeadPosition(); pos; m_rt.GetNext(pos)) + for(list::iterator i = m_rt.begin(); i != m_rt.end(); i++) { - GSRenderTarget* rt = m_rt.GetAt(pos); + GSRenderTarget* rt = *i; - if(rt->m_dirty.IsEmpty() && GSUtil::HasSharedBits(rt->m_TEX0.TBP0, rt->m_TEX0.PSM, TEX0.TBP0, TEX0.PSM)) + if(rt->m_dirty.empty() && GSUtil::HasSharedBits(rt->m_TEX0.TBP0, rt->m_TEX0.PSM, TEX0.TBP0, TEX0.PSM)) { t = CreateTexture(); @@ -496,7 +509,7 @@ public: return NULL; } - m_tex.AddHead(t); + m_tex.push_front(t); break; } @@ -505,11 +518,11 @@ public: if(t == NULL) { - for(POSITION pos = m_ds.GetHeadPosition(); pos; m_ds.GetNext(pos)) + for(list::iterator i = m_ds.begin(); i != m_ds.end(); i++) { - GSDepthStencil* ds = m_ds.GetAt(pos); + GSDepthStencil* ds = *i; - if(ds->m_dirty.IsEmpty() && ds->m_used && GSUtil::HasSharedBits(ds->m_TEX0.TBP0, ds->m_TEX0.PSM, TEX0.TBP0, TEX0.PSM)) + if(ds->m_dirty.empty() && ds->m_used && GSUtil::HasSharedBits(ds->m_TEX0.TBP0, ds->m_TEX0.PSM, TEX0.TBP0, TEX0.PSM)) { t = CreateTexture(); @@ -520,7 +533,7 @@ public: return NULL; } - m_tex.AddHead(t); + m_tex.push_front(t); break; } @@ -538,7 +551,7 @@ public: return NULL; } - m_tex.AddHead(t); + m_tex.push_front(t); } if(pal > 0) @@ -574,18 +587,16 @@ public: void InvalidateTextures(const GIFRegFRAME& FRAME, const GIFRegZBUF& ZBUF) { - POSITION pos = m_tex.GetHeadPosition(); - - while(pos) + for(list::iterator i = m_tex.begin(); i != m_tex.end(); ) { - POSITION cur = pos; + list::iterator j = i++; - GSTexture* t = m_tex.GetNext(pos); + GSTexture* t = *j; if(GSUtil::HasSharedBits(FRAME.Block(), FRAME.PSM, t->m_TEX0.TBP0, t->m_TEX0.PSM) || GSUtil::HasSharedBits(ZBUF.Block(), ZBUF.PSM, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { - m_tex.RemoveAt(cur); + m_tex.erase(j); delete t; } @@ -596,26 +607,23 @@ public: { bool found = false; - POSITION pos = m_tex.GetHeadPosition(); - - while(pos) + for(list::iterator i = m_tex.begin(); i != m_tex.end(); ) { - POSITION cur = pos; + list::iterator j = i++; - GSTexture* t = m_tex.GetNext(pos); + GSTexture* t = *j; if(GSUtil::HasSharedBits(BITBLTBUF.DBP, BITBLTBUF.DPSM, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { if(BITBLTBUF.DBW == t->m_TEX0.TBW && !t->m_rendered) { - t->m_dirty.AddTail(GSDirtyRect(BITBLTBUF.DPSM, r)); + t->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r)); found = true; } else { - m_tex.RemoveAt(cur); - + m_tex.erase(j); delete t; } } @@ -637,31 +645,29 @@ public: if(r2.bottom > 0 && r2.top < h && r2.right > 0 && r2.left < w) { - t->m_dirty.AddTail(GSDirtyRect(BITBLTBUF.DPSM, r2)); + t->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r2)); } } } } } - pos = m_rt.GetHeadPosition(); - - while(pos) + for(list::iterator i = m_rt.begin(); i != m_rt.end(); ) { - POSITION cur = pos; + list::iterator j = i++; - GSRenderTarget* rt = m_rt.GetNext(pos); + GSRenderTarget* rt = *j; if(GSUtil::HasSharedBits(BITBLTBUF.DBP, BITBLTBUF.DPSM, rt->m_TEX0.TBP0, rt->m_TEX0.PSM)) { if(!found && GSUtil::HasCompatibleBits(BITBLTBUF.DPSM, rt->m_TEX0.PSM)) { - rt->m_dirty.AddTail(GSDirtyRect(BITBLTBUF.DPSM, r)); + rt->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r)); rt->m_TEX0.TBW = BITBLTBUF.DBW; } else { - m_rt.RemoveAt(cur); + m_rt.erase(j); delete rt; continue; } @@ -679,7 +685,7 @@ public: if(r.bottom > y) { // TODO: do not add this rect above too - rt->m_dirty.AddTail(GSDirtyRect(BITBLTBUF.DPSM, CRect(r.left, r.top - y, r.right, r.bottom - y))); + rt->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, CRect(r.left, r.top - y, r.right, r.bottom - y))); rt->m_TEX0.TBW = BITBLTBUF.DBW; continue; } @@ -689,24 +695,22 @@ public: // copypaste for ds - pos = m_ds.GetHeadPosition(); - - while(pos) + for(list::iterator i = m_ds.begin(); i != m_ds.end(); ) { - POSITION cur = pos; + list::iterator j = i++; - GSDepthStencil* ds = m_ds.GetNext(pos); + GSDepthStencil* ds = *j; if(GSUtil::HasSharedBits(BITBLTBUF.DBP, BITBLTBUF.DPSM, ds->m_TEX0.TBP0, ds->m_TEX0.PSM)) { if(!found && GSUtil::HasCompatibleBits(BITBLTBUF.DPSM, ds->m_TEX0.PSM)) { - ds->m_dirty.AddTail(GSDirtyRect(BITBLTBUF.DPSM, r)); + ds->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r)); ds->m_TEX0.TBW = BITBLTBUF.DBW; } else { - m_ds.RemoveAt(cur); + m_ds.erase(j); delete ds; continue; } @@ -724,7 +728,7 @@ public: if(r.bottom > y) { // TODO: do not add this rect above too - ds->m_dirty.AddTail(GSDirtyRect(BITBLTBUF.DPSM, CRect(r.left, r.top - y, r.right, r.bottom - y))); + ds->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, CRect(r.left, r.top - y, r.right, r.bottom - y))); ds->m_TEX0.TBW = BITBLTBUF.DBW; continue; } @@ -736,13 +740,11 @@ public: void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const CRect& r) { - POSITION pos = m_rt.GetHeadPosition(); - - while(pos) + for(list::iterator i = m_rt.begin(); i != m_rt.end(); ) { - POSITION cur = pos; + list::iterator j = i++; - GSRenderTarget* rt = m_rt.GetNext(pos); + GSRenderTarget* rt = *j; if(GSUtil::HasSharedBits(BITBLTBUF.SBP, BITBLTBUF.SPSM, rt->m_TEX0.TBP0, rt->m_TEX0.PSM)) { @@ -760,7 +762,7 @@ public: } else { - m_rt.RemoveAt(cur); + m_rt.erase(j); delete rt; continue; } diff --git a/plugins/GSdx/GSTextureCache10.cpp b/plugins/GSdx/GSTextureCache10.cpp index 68c989325f..0ab8210bdc 100644 --- a/plugins/GSdx/GSTextureCache10.cpp +++ b/plugins/GSdx/GSTextureCache10.cpp @@ -39,7 +39,7 @@ void GSTextureCache10::GSRenderTargetHW10::Update() CRect r = m_dirty.GetDirtyRect(m_TEX0, m_texture.GetSize()); - m_dirty.RemoveAll(); + m_dirty.clear(); if(r.IsRectEmpty()) return; @@ -93,7 +93,7 @@ void GSTextureCache10::GSRenderTargetHW10::Read(CRect r) return; } - if(!m_dirty.IsEmpty()) + if(!m_dirty.empty()) { return; } diff --git a/plugins/GSdx/GSTextureCache9.cpp b/plugins/GSdx/GSTextureCache9.cpp index 31fe12f84a..52f733b4de 100644 --- a/plugins/GSdx/GSTextureCache9.cpp +++ b/plugins/GSdx/GSTextureCache9.cpp @@ -39,7 +39,7 @@ void GSTextureCache9::GSRenderTarget9::Update() CRect r = m_dirty.GetDirtyRect(m_TEX0, m_texture.GetSize()); - m_dirty.RemoveAll(); + m_dirty.clear(); if(r.IsRectEmpty()) return; @@ -96,7 +96,7 @@ void GSTextureCache9::GSRenderTarget9::Read(CRect r) return; } - if(!m_dirty.IsEmpty()) + if(!m_dirty.empty()) { return; } diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 9342c20dda..2aed3b6b64 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -38,16 +38,14 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM]; - const CAtlMap& map = m_map[TEX0.TBP0 >> 5]; + const hash_map& map = m_map[TEX0.TBP0 >> 5]; GSTexture* t = NULL; - POSITION pos = map.GetStartPosition(); - - while(pos) + for(hash_map::const_iterator i = map.begin(); i != map.end(); i++) { - GSTexture* t2 = map.GetNextKey(pos); - + GSTexture* t2 = (*i).first; + // if(t2->m_TEX0.TBP0 != TEX0.TBP0 || t2->m_TEX0.TBW != TEX0.TBW || t2->m_TEX0.PSM != TEX0.PSM || t2->m_TEX0.TW != TEX0.TW || t2->m_TEX0.TH != TEX0.TH) if(((t2->m_TEX0.ai32[0] ^ TEX0.ai32[0]) | ((t2->m_TEX0.ai32[1] ^ TEX0.ai32[1]) & 3)) != 0) { @@ -70,7 +68,7 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE { t = new GSTexture(m_state); - t->m_pos = m_textures.AddTail(t); + m_textures[t] = true; int tw = 1 << TEX0.TW; int th = 1 << TEX0.TH; @@ -93,7 +91,7 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE continue; } - m_map[page].SetAt(t, true); + m_map[page][t] = true; } } } @@ -102,11 +100,11 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE { printf("!@#$%\n"); // memory allocation may fail if the game is too hungry - m_textures.RemoveAt(t->m_pos); + m_textures.erase(t); for(int i = 0; i < MAX_PAGES; i++) { - m_map[i].RemoveKey(t); + m_map[i].erase(t); } delete t; @@ -119,38 +117,34 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE void GSTextureCacheSW::RemoveAll() { - POSITION pos = m_textures.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_textures.begin(); i != m_textures.end(); i++) { - delete m_textures.GetNext(pos); + delete i->first; } - m_textures.RemoveAll(); + m_textures.clear(); for(int i = 0; i < MAX_PAGES; i++) { - m_map[i].RemoveAll(); + m_map[i].clear(); } } void GSTextureCacheSW::IncAge() { - POSITION pos = m_textures.GetHeadPosition(); - - while(pos) + for(hash_map::iterator i = m_textures.begin(); i != m_textures.end(); ) { - POSITION cur = pos; + hash_map::iterator j = i++; - GSTexture* t = m_textures.GetNext(pos); + GSTexture* t = j->first; if(++t->m_age > 30) { - m_textures.RemoveAt(cur); + m_textures.erase(j); for(int i = 0; i < MAX_PAGES; i++) { - m_map[i].RemoveKey(t); + m_map[i].erase(t); } delete t; @@ -187,13 +181,11 @@ void GSTextureCacheSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, cons continue; } - const CAtlMap& map = m_map[page]; + const hash_map& map = m_map[page]; - POSITION pos = map.GetStartPosition(); - - while(pos) + for(hash_map::const_iterator i = map.begin(); i != map.end(); i++) { - GSTexture* t = map.GetNextKey(pos); + GSTexture* t = (*i).first; t->m_valid[page] = 0; @@ -210,7 +202,6 @@ GSTextureCacheSW::GSTexture::GSTexture(GSState* state) , m_buff(NULL) , m_tw(0) , m_age(0) - , m_pos(NULL) , m_complete(false) { memset(m_valid, 0, sizeof(m_valid)); diff --git a/plugins/GSdx/GSTextureCacheSW.h b/plugins/GSdx/GSTextureCacheSW.h index 1214c9e059..540cdd6e1b 100644 --- a/plugins/GSdx/GSTextureCacheSW.h +++ b/plugins/GSdx/GSTextureCacheSW.h @@ -39,7 +39,6 @@ public: DWORD m_tw; DWORD m_valid[MAX_PAGES]; // each DWORD bits map to the 32 blocks of that page DWORD m_age; - POSITION m_pos; bool m_complete; explicit GSTexture(GSState* state); @@ -50,8 +49,8 @@ public: protected: GSState* m_state; - CAtlList m_textures; - CAtlMap m_map[MAX_PAGES]; + hash_map m_textures; + hash_map m_map[MAX_PAGES]; public: GSTextureCacheSW(GSState* state); diff --git a/plugins/GSdx/GSTextureFX10.cpp b/plugins/GSdx/GSTextureFX10.cpp index 0f3073d9cf..80167bcc3a 100644 --- a/plugins/GSdx/GSTextureFX10.cpp +++ b/plugins/GSdx/GSTextureFX10.cpp @@ -163,27 +163,29 @@ bool GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb) { CComPtr vs; - if(CRBMap >::CPair* pair = m_vs.Lookup(sel)) + hash_map >::iterator i = m_vs.find(sel); + + if(i != m_vs.end()) { - vs = pair->m_value; + vs = (*i).second; } else { - CStringA str[5]; + string str[5]; - str[0].Format("%d", sel.bpp); - str[1].Format("%d", sel.bppz); - str[2].Format("%d", sel.tme); - str[3].Format("%d", sel.fst); - str[4].Format("%d", sel.prim); + str[0] = format("%d", sel.bpp); + str[1] = format("%d", sel.bppz); + str[2] = format("%d", sel.tme); + str[3] = format("%d", sel.fst); + str[4] = format("%d", sel.prim); D3D10_SHADER_MACRO macro[] = { - {"VS_BPP", str[0]}, - {"VS_BPPZ", str[1]}, - {"VS_TME", str[2]}, - {"VS_FST", str[3]}, - {"VS_PRIM", str[4]}, + {"VS_BPP", str[0].c_str()}, + {"VS_BPPZ", str[1].c_str()}, + {"VS_TME", str[2].c_str()}, + {"VS_FST", str[3].c_str()}, + {"VS_PRIM", str[4].c_str()}, {NULL, NULL}, }; @@ -206,7 +208,7 @@ bool GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb) m_il = il; } - m_vs.SetAt(sel, vs); + m_vs[sel] = vs; } if(m_vs_cb_cache.Update(cb)) @@ -227,27 +229,29 @@ bool GSTextureFX10::SetupGS(GSSelector sel) if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) // geometry shader works in every case, but not needed { - if(CRBMap >::CPair* pair = m_gs.Lookup(sel)) + hash_map >::iterator i = m_gs.find(sel); + + if(i != m_gs.end()) { - gs = pair->m_value; + gs = (*i).second; } else { - CStringA str[2]; + string str[2]; - str[0].Format("%d", sel.iip); - str[1].Format("%d", sel.prim); + str[0] = format("%d", sel.iip); + str[1] = format("%d", sel.prim); D3D10_SHADER_MACRO macro[] = { - {"IIP", str[0]}, - {"PRIM", str[1]}, + {"IIP", str[0].c_str()}, + {"PRIM", str[1].c_str()}, {NULL, NULL}, }; hr = m_dev->CompileShader(IDR_TFX10_FX, "gs_main", macro, &gs); - m_gs.SetAt(sel, gs); + m_gs[sel] = gs; } } @@ -271,49 +275,51 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl CComPtr ps; - if(CRBMap >::CPair* pair = m_ps.Lookup(sel)) + hash_map >::iterator i = m_ps.find(sel); + + if(i != m_ps.end()) { - ps = pair->m_value; + ps = (*i).second; } else { - CStringA str[13]; + string str[13]; - str[0].Format("%d", sel.fst); - str[1].Format("%d", sel.wms); - str[2].Format("%d", sel.wmt); - str[3].Format("%d", sel.bpp); - str[4].Format("%d", sel.aem); - str[5].Format("%d", sel.tfx); - str[6].Format("%d", sel.tcc); - str[7].Format("%d", sel.ate); - str[8].Format("%d", sel.atst); - str[9].Format("%d", sel.fog); - str[10].Format("%d", sel.clr1); - str[11].Format("%d", sel.fba); - str[12].Format("%d", sel.aout); + str[0] = format("%d", sel.fst); + str[1] = format("%d", sel.wms); + str[2] = format("%d", sel.wmt); + str[3] = format("%d", sel.bpp); + str[4] = format("%d", sel.aem); + str[5] = format("%d", sel.tfx); + str[6] = format("%d", sel.tcc); + str[7] = format("%d", sel.ate); + str[8] = format("%d", sel.atst); + str[9] = format("%d", sel.fog); + str[10] = format("%d", sel.clr1); + str[11] = format("%d", sel.fba); + str[12] = format("%d", sel.aout); D3D10_SHADER_MACRO macro[] = { - {"FST", str[0]}, - {"WMS", str[1]}, - {"WMT", str[2]}, - {"BPP", str[3]}, - {"AEM", str[4]}, - {"TFX", str[5]}, - {"TCC", str[6]}, - {"ATE", str[7]}, - {"ATST", str[8]}, - {"FOG", str[9]}, - {"CLR1", str[10]}, - {"FBA", str[11]}, - {"AOUT", str[12]}, + {"FST", str[0].c_str()}, + {"WMS", str[1].c_str()}, + {"WMT", str[2].c_str()}, + {"BPP", str[3].c_str()}, + {"AEM", str[4].c_str()}, + {"TFX", str[5].c_str()}, + {"TCC", str[6].c_str()}, + {"ATE", str[7].c_str()}, + {"ATST", str[8].c_str()}, + {"FOG", str[9].c_str()}, + {"CLR1", str[10].c_str()}, + {"FBA", str[11].c_str()}, + {"AOUT", str[12].c_str()}, {NULL, NULL}, }; hr = m_dev->CompileShader(IDR_TFX10_FX, "ps_main", macro, &ps); - m_ps.SetAt(sel, ps); + m_ps[sel] = ps; } if(m_ps_cb_cache.Update(cb)) @@ -332,9 +338,11 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl ssel.min = ssel.mag = 0; } - if(CRBMap >::CPair* pair = m_ps_ss.Lookup(ssel)) + hash_map >::iterator i = m_ps_ss.find(ssel); + + if(i != m_ps_ss.end()) { - ss0 = pair->m_value; + ss0 = (*i).second; } else { @@ -358,7 +366,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl hr = (*m_dev)->CreateSamplerState(&sd, &ss0); - m_ps_ss.SetAt(ssel, ss0); + m_ps_ss[ssel] = ss0; } if(sel.bpp == 3) @@ -388,9 +396,11 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, CComPtr dss; - if(CRBMap >::CPair* pair = m_om_dss.Lookup(dssel)) + hash_map >::iterator i = m_om_dss.find(dssel); + + if(i != m_om_dss.end()) { - dss = pair->m_value; + dss = (*i).second; } else { @@ -430,16 +440,18 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, hr = (*m_dev)->CreateDepthStencilState(&dsd, &dss); - m_om_dss.SetAt(dssel, dss); + m_om_dss[dssel] = dss; } m_dev->OMSetDepthStencilState(dss, 1); CComPtr bs; - if(CRBMap >::CPair* pair = m_om_bs.Lookup(bsel)) + hash_map >::iterator j = m_om_bs.find(bsel); + + if(j != m_om_bs.end()) { - bs = pair->m_value; + bs = (*j).second; } else { @@ -571,7 +583,7 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, hr = (*m_dev)->CreateBlendState(&bd, &bs); - m_om_bs.SetAt(bsel, bs); + m_om_bs[bsel] = bs; } m_dev->OMSetBlendState(bs, bf); diff --git a/plugins/GSdx/GSTextureFX10.h b/plugins/GSdx/GSTextureFX10.h index 6dcaedc29e..7c554e66c1 100644 --- a/plugins/GSdx/GSTextureFX10.h +++ b/plugins/GSdx/GSTextureFX10.h @@ -213,15 +213,15 @@ public: private: GSDevice10* m_dev; CComPtr m_il; - CRBMapC > m_vs; + hash_map > m_vs; CComPtr m_vs_cb; - CRBMapC > m_gs; - CRBMapC > m_ps; + hash_map > m_gs; + hash_map > m_ps; CComPtr m_ps_cb; - CRBMapC > m_ps_ss; + hash_map > m_ps_ss; CComPtr m_palette_ss; - CRBMapC > m_om_dss; - CRBMapC > m_om_bs; + hash_map > m_om_dss; + hash_map > m_om_bs; CComPtr m_vb, m_vb_old; int m_vb_max; diff --git a/plugins/GSdx/GSTextureFX9.cpp b/plugins/GSdx/GSTextureFX9.cpp index 82c213d165..c6709d9e1f 100644 --- a/plugins/GSdx/GSTextureFX9.cpp +++ b/plugins/GSdx/GSTextureFX9.cpp @@ -50,9 +50,11 @@ bool GSTextureFX9::CreateMskFix(GSTexture9& t, DWORD size, DWORD msk, DWORD fix) { DWORD hash = (size << 20) | (msk << 10) | fix; - if(CRBMap::CPair* pair = m_mskfix.Lookup(hash)) + hash_map::iterator i = m_mskfix.find(hash); + + if(i != m_mskfix.end()) { - t = pair->m_value; + t = (*i).second; } else { @@ -74,7 +76,7 @@ bool GSTextureFX9::CreateMskFix(GSTexture9& t, DWORD size, DWORD msk, DWORD fix) t.Unmap(); } - m_mskfix.SetAt(hash, t); + m_mskfix[hash] = t; } return true; @@ -93,25 +95,27 @@ bool GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb) { CComPtr vs; - if(CRBMap >::CPair* pair = m_vs.Lookup(sel)) + hash_map >::iterator i = m_vs.find(sel); + + if(i != m_vs.end()) { - vs = pair->m_value; + vs = (*i).second; } else { - CStringA str[4]; + string str[4]; - str[0].Format("%d", sel.bppz); - str[1].Format("%d", sel.tme); - str[2].Format("%d", sel.fst); - str[3].Format("%d", sel.logz); + str[0] = format("%d", sel.bppz); + str[1] = format("%d", sel.tme); + str[2] = format("%d", sel.fst); + str[3] = format("%d", sel.logz); D3DXMACRO macro[] = { - {"VS_BPPZ", str[0]}, - {"VS_TME", str[1]}, - {"VS_FST", str[2]}, - {"VS_LOGZ", str[3]}, + {"VS_BPPZ", str[0].c_str()}, + {"VS_TME", str[1].c_str()}, + {"VS_FST", str[2].c_str()}, + {"VS_LOGZ", str[3].c_str()}, {NULL, NULL}, }; @@ -133,7 +137,7 @@ bool GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb) m_il = il; } - m_vs.SetAt(sel, vs); + m_vs[sel] = vs; } m_dev->VSSetShader(vs, (const float*)cb, sizeof(*cb) / sizeof(GSVector4)); @@ -187,47 +191,49 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample CComPtr ps; - if(CRBMap >::CPair* pair = m_ps.Lookup(sel)) + hash_map >::iterator i = m_ps.find(sel); + + if(i != m_ps.end()) { - ps = pair->m_value; + ps = (*i).second; } else { - CStringA str[12]; + string str[12]; - str[0].Format("%d", sel.fst); - str[1].Format("%d", sel.wms); - str[2].Format("%d", sel.wmt); - str[3].Format("%d", sel.bpp); - str[4].Format("%d", sel.aem); - str[5].Format("%d", sel.tfx); - str[6].Format("%d", sel.tcc); - str[7].Format("%d", sel.ate); - str[8].Format("%d", sel.atst); - str[9].Format("%d", sel.fog); - str[10].Format("%d", sel.clr1); - str[11].Format("%d", sel.rt); + str[0] = format("%d", sel.fst); + str[1] = format("%d", sel.wms); + str[2] = format("%d", sel.wmt); + str[3] = format("%d", sel.bpp); + str[4] = format("%d", sel.aem); + str[5] = format("%d", sel.tfx); + str[6] = format("%d", sel.tcc); + str[7] = format("%d", sel.ate); + str[8] = format("%d", sel.atst); + str[9] = format("%d", sel.fog); + str[10] = format("%d", sel.clr1); + str[11] = format("%d", sel.rt); D3DXMACRO macro[] = { - {"FST", str[0]}, - {"WMS", str[1]}, - {"WMT", str[2]}, - {"BPP", str[3]}, - {"AEM", str[4]}, - {"TFX", str[5]}, - {"TCC", str[6]}, - {"ATE", str[7]}, - {"ATST", str[8]}, - {"FOG", str[9]}, - {"CLR1", str[10]}, - {"RT", str[11]}, + {"FST", str[0].c_str()}, + {"WMS", str[1].c_str()}, + {"WMT", str[2].c_str()}, + {"BPP", str[3].c_str()}, + {"AEM", str[4].c_str()}, + {"TFX", str[5].c_str()}, + {"TCC", str[6].c_str()}, + {"ATE", str[7].c_str()}, + {"ATST", str[8].c_str()}, + {"FOG", str[9].c_str()}, + {"CLR1", str[10].c_str()}, + {"RT", str[11].c_str()}, {NULL, NULL}, }; hr = m_dev->CompileShader(IDR_TFX9_FX, "ps_main", macro, &ps); - m_ps.SetAt(sel, ps); + m_ps[sel] = ps; } m_dev->PSSetShader(ps, (const float*)cb, sizeof(*cb) / sizeof(GSVector4)); @@ -241,9 +247,11 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample ssel.min = ssel.mag = 0; } - if(CRBMap::CPair* pair = m_ps_ss.Lookup(ssel)) + hash_map::iterator i = m_ps_ss.find(ssel); + + if(i != m_ps_ss.end()) { - ss = pair->m_value; + ss = (*i).second; } else { @@ -259,7 +267,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample ss->AddressU = ssel.tau ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP; ss->AddressV = ssel.tav ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP; - m_ps_ss.SetAt(ssel, ss); + m_ps_ss[ssel] = ss; } } @@ -282,9 +290,11 @@ void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, { Direct3DDepthStencilState9* dss = NULL; - if(CRBMap::CPair* pair = m_om_dss.Lookup(dssel)) + hash_map::iterator i = m_om_dss.find(dssel); + + if(i != m_om_dss.end()) { - dss = pair->m_value; + dss = (*i).second; } else { @@ -318,16 +328,18 @@ void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, dss->DepthFunc = ztst[dssel.ztst]; } - m_om_dss.SetAt(dssel, dss); + m_om_dss[dssel] = dss; } m_dev->OMSetDepthStencilState(dss, 3); Direct3DBlendState9* bs = NULL; - if(CRBMap::CPair* pair = m_om_bs.Lookup(bsel)) + hash_map::iterator j = m_om_bs.find(bsel); + + if(j != m_om_bs.end()) { - bs = pair->m_value; + bs = (*j).second; } else { @@ -457,7 +469,7 @@ void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, if(bsel.wb) bs->RenderTargetWriteMask |= D3DCOLORWRITEENABLE_BLUE; if(bsel.wa) bs->RenderTargetWriteMask |= D3DCOLORWRITEENABLE_ALPHA; - m_om_bs.SetAt(bsel, bs); + m_om_bs[bsel] = bs; } m_dev->OMSetBlendState(bs, 0x010101 * bf); diff --git a/plugins/GSdx/GSTextureFX9.h b/plugins/GSdx/GSTextureFX9.h index e2811059c9..a8c1ab9a3f 100644 --- a/plugins/GSdx/GSTextureFX9.h +++ b/plugins/GSdx/GSTextureFX9.h @@ -149,13 +149,13 @@ public: private: GSDevice9* m_dev; CComPtr m_il; - CRBMapC > m_vs; + hash_map > m_vs; D3DXHANDLE m_vs_params; - CRBMapC > m_ps; - CRBMapC m_ps_ss; - CRBMapC m_om_dss; - CRBMapC m_om_bs; - CRBMapC m_mskfix; + hash_map > m_ps; + hash_map m_ps_ss; + hash_map m_om_dss; + hash_map m_om_bs; + hash_map m_mskfix; public: GSTextureFX9(); diff --git a/plugins/GSdx/GSTextureNull.h b/plugins/GSdx/GSTextureNull.h index 38f21990fe..1d6e07868b 100644 --- a/plugins/GSdx/GSTextureNull.h +++ b/plugins/GSdx/GSTextureNull.h @@ -40,5 +40,5 @@ public: bool Update(const CRect& r, const void* data, int pitch) {return true;} bool Map(BYTE** bits, int& pitch, const RECT* r = NULL) {return true;} void Unmap() {} - bool Save(CString fn, bool dds = false) {return false;} + bool Save(const string& fn, bool dds = false) {return false;} }; diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp index 4f06fe7fe9..b6f391ddf3 100644 --- a/plugins/GSdx/GSUtil.cpp +++ b/plugins/GSdx/GSUtil.cpp @@ -148,11 +148,7 @@ void GSUtil::FitRect(CRect& r, int aspectratio) bool GSUtil::CheckDirectX() { - CString str; - - str.Format(_T("d3dx9_%d.dll"), D3DX_SDK_VERSION); - - if(HINSTANCE hDll = LoadLibrary(str)) + if(HINSTANCE hDll = LoadLibrary(format("d3dx9_%d.dll", D3DX_SDK_VERSION).c_str())) { FreeLibrary(hDll); } @@ -199,9 +195,9 @@ bool GSUtil::CheckSSE() { if(!_CheckSSE()) { - CString str; - str.Format(_T("This CPU does not support SSE %d.%02d"), _M_SSE >> 8, _M_SSE & 0xff); - AfxMessageBox(str, MB_OK); + string s = format("This CPU does not support SSE %d.%02d", _M_SSE >> 8, _M_SSE & 0xff); + + AfxMessageBox(s.c_str(), MB_OK); return false; } @@ -223,50 +219,40 @@ bool GSUtil::IsDirect3D10Available() char* GSUtil::GetLibName() { - CString str; + static string str = format("GSdx %d", SVN_REV); - str.Format(_T("GSdx %d"), SVN_REV); - - if(SVN_MODS) str += _T("m"); + if(SVN_MODS) str += "m"; #if _M_AMD64 - str += _T(" 64-bit"); + str += " 64-bit"; #endif - CAtlList sl; + list sl; #ifdef __INTEL_COMPILER - CString s; - s.Format(_T("Intel C++ %d.%02d"), __INTEL_COMPILER/100, __INTEL_COMPILER%100); - sl.AddTail(s); + sl.push_back(format("Intel C++ %d.%02d", __INTEL_COMPILER / 100, __INTEL_COMPILER % 100)); #elif _MSC_VER - CString s; - s.Format(_T("MSVC %d.%02d"), _MSC_VER/100, _MSC_VER%100); - sl.AddTail(s); + sl.push_back(format("MSVC %d.%02d", _MSC_VER / 100, _MSC_VER % 100)); #endif #if _M_SSE >= 0x402 - sl.AddTail(_T("SSE42")); + sl.push_back("SSE42"); #elif _M_SSE >= 0x401 - sl.AddTail(_T("SSE41")); + sl.push_back("SSE41"); #elif _M_SSE >= 0x301 - sl.AddTail(_T("SSSE3")); + sl.push_back("SSSE3"); #elif _M_SSE >= 0x200 - sl.AddTail(_T("SSE2")); + sl.push_back("SSE2"); #elif _M_SSE >= 0x100 - sl.AddTail(_T("SSE")); + sl.push_back("SSE"); #endif - POSITION pos = sl.GetHeadPosition(); - - while(pos) + for(list::iterator i = sl.begin(); i != sl.end(); ) { - if(pos == sl.GetHeadPosition()) str += _T(" ("); - str += sl.GetNext(pos); - str += pos ? _T(", ") : _T(")"); + if(i == sl.begin()) str += " ("; + str += *i; + str += ++i != sl.end() ? ", " : ")"; } - static char buff[256]; - strncpy(buff, CStringA(str), min(countof(buff)-1, str.GetLength())); - return buff; + return (char*)str.c_str(); } \ No newline at end of file diff --git a/plugins/GSdx/GSVector.h b/plugins/GSdx/GSVector.h index 1d98b97822..2f413e3a0a 100644 --- a/plugins/GSdx/GSVector.h +++ b/plugins/GSdx/GSVector.h @@ -35,8 +35,8 @@ public: } }; -typedef __declspec(align(8)) GSVector2T GSVector2; -typedef __declspec(align(8)) GSVector2T GSVector2i; +typedef GSVector2T GSVector2; +typedef GSVector2T GSVector2i; class GSVector4; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index f2d195a99c..c01f3390bb 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -35,7 +35,7 @@ GSWnd::~GSWnd() DestroyWindow(); } -bool GSWnd::Create(LPCTSTR title) +bool GSWnd::Create(const string& title) { CRect r; @@ -53,7 +53,7 @@ bool GSWnd::Create(LPCTSTR title) LPCTSTR wc = AfxRegisterWndClass(CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS, AfxGetApp()->LoadStandardCursor(IDC_ARROW), 0, 0); - return !!CreateEx(0, wc, title, WS_OVERLAPPEDWINDOW, r, NULL, 0); + return !!CreateEx(0, wc, title.c_str(), WS_OVERLAPPEDWINDOW, r, NULL, 0); } void GSWnd::Show() diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index aa76393b6f..4de785f724 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -29,7 +29,7 @@ public: GSWnd(); virtual ~GSWnd(); - virtual bool Create(LPCTSTR title); + virtual bool Create(const string& title); void Show(); void Hide(); diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 799d55ea5c..48a30d5e92 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -21,6 +21,8 @@ #include "stdafx.h" #include "GSdx.h" +#include +#include // // Note! diff --git a/plugins/GSdx/stdafx.cpp b/plugins/GSdx/stdafx.cpp index bda8426831..7811c93b2e 100644 --- a/plugins/GSdx/stdafx.cpp +++ b/plugins/GSdx/stdafx.cpp @@ -6,3 +6,34 @@ // TODO: reference any additional headers you need in STDAFX.H // and not in this file + +string format(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + + int result = -1, length = 256; + + char* buffer = NULL; + + while(result == -1) + { + if(buffer) delete [] buffer; + + buffer = new char[length + 1]; + + memset(buffer, 0, length + 1); + + result = _vsnprintf(buffer, length, fmt, args); + + length *= 2; + } + + va_end(args); + + string s(buffer); + + delete [] buffer; + + return s; +} diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 826f5a6029..8b3acecd95 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -36,9 +36,6 @@ #include // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT //#include -#include -#include -#include #include #include #include @@ -46,6 +43,17 @@ #include #include +#include +#include +#include +#include +#include + +using namespace std; +using namespace stdext; + +extern string format(const char* fmt, ...); + #if !defined(_M_SSE) && (defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2) #define _M_SSE 0x200 #endif @@ -73,35 +81,3 @@ #define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RGB|D3DCOLORWRITEENABLE_ALPHA) #define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) : - -template class CRBMapC : public CRBMap -{ - // CRBMap + a cache for the last value (simple, but already a lot better) - - CPair* m_pair; - -public: - CRBMapC() : m_pair(NULL) {} - - CPair* Lookup(KINARGTYPE key) - { - if(m_pair && key == m_pair->m_key) - { - return m_pair; - } - - m_pair = __super::Lookup(key); - - return m_pair; - } - - POSITION SetAt(KINARGTYPE key, VINARGTYPE value) - { - POSITION pos = __super::SetAt(key, value); - - m_pair = __super::GetAt(pos); - - return pos; - } -}; -