diff --git a/Utilities/IdManager.h b/Utilities/IdManager.h index 4e95b29b51..527fcb320f 100644 --- a/Utilities/IdManager.h +++ b/Utilities/IdManager.h @@ -34,12 +34,12 @@ public: struct ID { - wxString m_name; + std::string m_name; u8 m_attr; IDData* m_data; template - ID(const wxString& name, T* data, const u8 attr) + ID(const std::string& name, T* data, const u8 attr) : m_name(name) , m_attr(attr) { @@ -58,8 +58,6 @@ struct ID class IdManager { - ArrayF IDs; - static const ID_TYPE s_first_id = 1; static const ID_TYPE s_max_id = -1; @@ -99,7 +97,7 @@ public: } template - ID_TYPE GetNewID(const wxString& name = wxEmptyString, T* data = nullptr, const u8 attr = 0) + ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u8 attr = 0) { std::lock_guard lock(m_mtx_main); diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index eab5e860d4..17c58d3ef6 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1,29 +1,11 @@ #include "stdafx.h" #include "Thread.h" -static DWORD g_tls_this_thread = 0xFFFFFFFF; - -struct __init_tls -{ - //NamedThreadBase m_main_thr; - - __init_tls() - { - g_tls_this_thread = ::TlsAlloc(); - //m_main_thr.SetThreadName("Main Thread"); - //::TlsSetValue(g_tls_this_thread, &m_main_thr); - ::TlsSetValue(g_tls_this_thread, nullptr); - } - - ~__init_tls() - { - ::TlsFree(g_tls_this_thread); - } -} _init_tls; +__declspec(thread) NamedThreadBase* g_tls_this_thread = nullptr; NamedThreadBase* GetCurrentNamedThread() { - return (NamedThreadBase*)::TlsGetValue(g_tls_this_thread); + return g_tls_this_thread; } std::string NamedThreadBase::GetThreadName() const @@ -62,7 +44,7 @@ void ThreadBase::Start() m_executor = new std::thread( [this]() { - ::TlsSetValue(g_tls_this_thread, this); + g_tls_this_thread = this; Task(); @@ -130,7 +112,7 @@ thread::thread() void thread::start(std::function func) { - m_thr = std::thread([this, func]() { NamedThreadBase info(m_name); ::TlsSetValue(g_tls_this_thread, &info); func(); }); + m_thr = std::thread([this, func]() { NamedThreadBase info(m_name); g_tls_this_thread = &info; func(); }); } void thread::detach() diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 54a5ae6a8c..1a412ea121 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -109,7 +109,7 @@ protected: CPUThread(CPUThreadType type); public: - ~CPUThread(); + virtual ~CPUThread(); u32 m_wait_thread_id; diff --git a/rpcs3/Emu/Cell/PPCThread.cpp b/rpcs3/Emu/Cell/PPCThread.cpp index fb92104aa4..c29057d81f 100644 --- a/rpcs3/Emu/Cell/PPCThread.cpp +++ b/rpcs3/Emu/Cell/PPCThread.cpp @@ -20,7 +20,6 @@ PPCThread::PPCThread(CPUThreadType type) : CPUThread(type) PPCThread::~PPCThread() { - Close(); } void PPCThread::DoReset() diff --git a/rpcs3/Emu/Cell/PPCThread.h b/rpcs3/Emu/Cell/PPCThread.h index c4d794d281..a6e35ed8d5 100644 --- a/rpcs3/Emu/Cell/PPCThread.h +++ b/rpcs3/Emu/Cell/PPCThread.h @@ -24,7 +24,7 @@ protected: PPCThread(CPUThreadType type); public: - ~PPCThread(); + virtual ~PPCThread(); protected: virtual void DoReset() override; diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 2886049787..6bf0f5337b 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -22,7 +22,6 @@ PPUThread::PPUThread() : PPCThread(CPU_THREAD_PPU) PPUThread::~PPUThread() { - //~PPCThread(); } void PPUThread::DoReset() diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index fa63ae9800..c85f15fd1b 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -370,14 +370,14 @@ struct PPCdouble case _FPCLASS_PINF: return FPR_PINF; } #else - switch (fpc) - { - case FP_NAN: return FPR_QNAN; - case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF; - case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD; - case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ; - default: return signbit(_double) ? FPR_NN : FPR_PN; - } + switch (fpc) + { + case FP_NAN: return FPR_QNAN; + case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF; + case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD; + case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ; + default: return signbit(_double) ? FPR_NN : FPR_PN; + } #endif throw wxString::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc); @@ -609,7 +609,7 @@ public: public: PPUThread(); - ~PPUThread(); + virtual ~PPUThread(); inline u8 GetCR(const u8 n) const { diff --git a/rpcs3/Emu/Cell/RawSPUThread.h b/rpcs3/Emu/Cell/RawSPUThread.h index 2227a4cdc0..5a19973afc 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.h +++ b/rpcs3/Emu/Cell/RawSPUThread.h @@ -50,7 +50,7 @@ class RawSPUThread public: RawSPUThread(u32 index, CPUThreadType type = CPU_THREAD_RAW_SPU); - ~RawSPUThread(); + virtual ~RawSPUThread(); virtual bool Read8(const u64 addr, u8* value) override; virtual bool Read16(const u64 addr, u16* value) override; diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 4e876195c9..e6a446c94b 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -698,7 +698,7 @@ public: public: SPUThread(CPUThreadType type = CPU_THREAD_SPU); - ~SPUThread(); + virtual ~SPUThread(); virtual wxString RegsToString() { diff --git a/rpcs3/Emu/FS/vfsDirBase.cpp b/rpcs3/Emu/FS/vfsDirBase.cpp index 0d29a26585..97ff25cde9 100644 --- a/rpcs3/Emu/FS/vfsDirBase.cpp +++ b/rpcs3/Emu/FS/vfsDirBase.cpp @@ -1,3 +1,44 @@ #include "stdafx.h" #include "vfsDirBase.h" +vfsDirBase::vfsDirBase(const wxString& path) +{ + Open(path); +} + +vfsDirBase::~vfsDirBase() +{ +} + +bool vfsDirBase::Open(const wxString& path) +{ + if(!IsOpened()) + Close(); + + if(!IsExists(path)) + return false; + + m_cwd += '/' + path; + return true; +} + +bool vfsDirBase::IsOpened() const +{ + return !m_cwd.IsEmpty(); +} + +const Array& vfsDirBase::GetEntryes() const +{ + return m_entryes; +} + +void vfsDirBase::Close() +{ + m_cwd = wxEmptyString; + m_entryes.Clear(); +} + +wxString vfsDirBase::GetPath() const +{ + return m_cwd; +} \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsDirBase.h b/rpcs3/Emu/FS/vfsDirBase.h index 969a2d1df5..74f0b7ebef 100644 --- a/rpcs3/Emu/FS/vfsDirBase.h +++ b/rpcs3/Emu/FS/vfsDirBase.h @@ -1,19 +1,51 @@ #pragma once -struct DirInfo +enum DirEntryFlags { - wxString m_name; + DirEntry_TypeDir = 0x0, + DirEntry_TypeFile = 0x1, + DirEntry_TypeMask = 0x1, + DirEntry_PermWritable = 0x20, + DirEntry_PermReadable = 0x40, + DirEntry_PermExecutable = 0x80, +}; +struct DirEntryInfo +{ + wxString name; + u32 flags; + time_t create_time; + time_t access_time; + time_t modify_time; + + DirEntryInfo() + : flags(0) + , create_time(0) + , access_time(0) + , modify_time(0) + { + } }; class vfsDirBase { - virtual bool Open(const wxString& path)=0; - virtual Array GetEntryes()=0; - virtual void Close()=0; +protected: + wxString m_cwd; + Array m_entryes; + +public: + vfsDirBase(const wxString& path); + virtual ~vfsDirBase(); + + virtual bool Open(const wxString& path); + virtual bool IsOpened() const; + virtual const Array& GetEntryes() const; + virtual void Close(); + virtual wxString GetPath() const; virtual bool Create(const wxString& path)=0; - virtual bool Exists(const wxString& path)=0; + //virtual bool Create(const DirEntryInfo& info)=0; + virtual bool IsExists(const wxString& path) const=0; virtual bool Rename(const wxString& from, const wxString& to)=0; virtual bool Remove(const wxString& path)=0; }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsLocalDir.cpp b/rpcs3/Emu/FS/vfsLocalDir.cpp new file mode 100644 index 0000000000..bfeea4145b --- /dev/null +++ b/rpcs3/Emu/FS/vfsLocalDir.cpp @@ -0,0 +1,58 @@ +#include "stdafx.h" +#include "vfsLocalDir.h" +#include + +vfsLocalDir::vfsLocalDir(const wxString& path) : vfsDirBase(path) +{ +} + +vfsLocalDir::~vfsLocalDir() +{ +} + +bool vfsLocalDir::Open(const wxString& path) +{ + if(!vfsDirBase::Open(path)) + return false; + + wxDir dir; + + if(!dir.Open(path)) + return false; + + wxString name; + for(bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name)) + { + wxString dir_path = path + wxFILE_SEP_PATH + name; + + DirEntryInfo& info = m_entryes[m_entryes.Add(new DirEntryInfo())]; + info.name = name; + + info.flags |= wxDirExists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile; + if(wxIsWritable(dir_path)) info.flags |= DirEntry_PermWritable; + if(wxIsReadable(dir_path)) info.flags |= DirEntry_PermReadable; + if(wxIsExecutable(dir_path)) info.flags |= DirEntry_PermExecutable; + } + + return true; +} + +bool vfsLocalDir::Create(const wxString& path) +{ + return wxFileName::Mkdir(path, 0777, wxPATH_MKDIR_FULL); +} + +bool vfsLocalDir::IsExists(const wxString& path) const +{ + return wxDirExists(path); +} + +bool vfsLocalDir::Rename(const wxString& from, const wxString& to) +{ + return false; +} + +bool vfsLocalDir::Remove(const wxString& path) +{ + return wxRmdir(path); +} \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsLocalDir.h b/rpcs3/Emu/FS/vfsLocalDir.h new file mode 100644 index 0000000000..7e4fb7fe15 --- /dev/null +++ b/rpcs3/Emu/FS/vfsLocalDir.h @@ -0,0 +1,16 @@ +#pragma once +#include "vfsDirBase.h" + +class vfsLocalDir : public vfsDirBase +{ +public: + vfsLocalDir(const wxString& path = wxEmptyString); + virtual ~vfsLocalDir(); + + virtual bool Open(const wxString& path) override; + + virtual bool Create(const wxString& path) override; + virtual bool IsExists(const wxString& path) const override; + virtual bool Rename(const wxString& from, const wxString& to) override; + virtual bool Remove(const wxString& path) override; +}; \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp index fc55c3241e..6e6fd21d2d 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp @@ -133,10 +133,11 @@ std::string GLFragmentDecompilerThread::AddCond(int fp16) std::string GLFragmentDecompilerThread::AddConst() { - if(m_parr.HasParam(PARAM_UNIFORM, "vec4", std::string("fc") + std::to_string(m_size + 4 * 4))) - { - return std::string("fc") + std::to_string(m_size + 4 * 4); - } + std::string name = std::string("fc") + std::to_string(m_size + 4 * 4); + if(m_parr.HasParam(PARAM_UNIFORM, "vec4", name)) + { + return name; + } mem32_ptr_t data(m_addr + m_size + m_offset); @@ -145,7 +146,7 @@ std::string GLFragmentDecompilerThread::AddConst() u32 y = GetData(data[1]); u32 z = GetData(data[2]); u32 w = GetData(data[3]); - return m_parr.AddParam(PARAM_UNIFORM, "vec4", std::string("fc") + std::to_string(m_size + 4 * 4), + return m_parr.AddParam(PARAM_UNIFORM, "vec4", name, std::string("vec4(") + std::to_string((float&)x) + ", " + std::to_string((float&)y) + ", " + std::to_string((float&)z) + ", " + std::to_string((float&)w) + ")"); } diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index e8e50cafc2..785038e535 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -221,8 +221,10 @@ + + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 45dd7d3051..abbb2365a1 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -373,6 +373,12 @@ Emu\SysCalls\lv2 + + Emu\FS + + + Emu\FS +