mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
Implemented vfsLocalDir & vfsDirBase.
Improved ThreadBase. Minor fixes.
This commit is contained in:
parent
16c284214f
commit
beb19633e9
@ -34,12 +34,12 @@ public:
|
||||
|
||||
struct ID
|
||||
{
|
||||
wxString m_name;
|
||||
std::string m_name;
|
||||
u8 m_attr;
|
||||
IDData* m_data;
|
||||
|
||||
template<typename T>
|
||||
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<ID> IDs;
|
||||
|
||||
static const ID_TYPE s_first_id = 1;
|
||||
static const ID_TYPE s_max_id = -1;
|
||||
|
||||
@ -99,7 +97,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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<std::mutex> lock(m_mtx_main);
|
||||
|
||||
|
@ -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<void()> 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()
|
||||
|
@ -109,7 +109,7 @@ protected:
|
||||
CPUThread(CPUThreadType type);
|
||||
|
||||
public:
|
||||
~CPUThread();
|
||||
virtual ~CPUThread();
|
||||
|
||||
u32 m_wait_thread_id;
|
||||
|
||||
|
@ -20,7 +20,6 @@ PPCThread::PPCThread(CPUThreadType type) : CPUThread(type)
|
||||
|
||||
PPCThread::~PPCThread()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void PPCThread::DoReset()
|
||||
|
@ -24,7 +24,7 @@ protected:
|
||||
PPCThread(CPUThreadType type);
|
||||
|
||||
public:
|
||||
~PPCThread();
|
||||
virtual ~PPCThread();
|
||||
|
||||
protected:
|
||||
virtual void DoReset() override;
|
||||
|
@ -22,7 +22,6 @@ PPUThread::PPUThread() : PPCThread(CPU_THREAD_PPU)
|
||||
|
||||
PPUThread::~PPUThread()
|
||||
{
|
||||
//~PPCThread();
|
||||
}
|
||||
|
||||
void PPUThread::DoReset()
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -698,7 +698,7 @@ public:
|
||||
|
||||
public:
|
||||
SPUThread(CPUThreadType type = CPU_THREAD_SPU);
|
||||
~SPUThread();
|
||||
virtual ~SPUThread();
|
||||
|
||||
virtual wxString RegsToString()
|
||||
{
|
||||
|
@ -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<DirEntryInfo>& vfsDirBase::GetEntryes() const
|
||||
{
|
||||
return m_entryes;
|
||||
}
|
||||
|
||||
void vfsDirBase::Close()
|
||||
{
|
||||
m_cwd = wxEmptyString;
|
||||
m_entryes.Clear();
|
||||
}
|
||||
|
||||
wxString vfsDirBase::GetPath() const
|
||||
{
|
||||
return m_cwd;
|
||||
}
|
@ -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<DirInfo> GetEntryes()=0;
|
||||
virtual void Close()=0;
|
||||
protected:
|
||||
wxString m_cwd;
|
||||
Array<DirEntryInfo> m_entryes;
|
||||
|
||||
public:
|
||||
vfsDirBase(const wxString& path);
|
||||
virtual ~vfsDirBase();
|
||||
|
||||
virtual bool Open(const wxString& path);
|
||||
virtual bool IsOpened() const;
|
||||
virtual const Array<DirEntryInfo>& 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;
|
||||
};
|
58
rpcs3/Emu/FS/vfsLocalDir.cpp
Normal file
58
rpcs3/Emu/FS/vfsLocalDir.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "stdafx.h"
|
||||
#include "vfsLocalDir.h"
|
||||
#include <direct.h>
|
||||
|
||||
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);
|
||||
}
|
16
rpcs3/Emu/FS/vfsLocalDir.h
Normal file
16
rpcs3/Emu/FS/vfsLocalDir.h
Normal file
@ -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;
|
||||
};
|
@ -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) + ")");
|
||||
}
|
||||
|
@ -221,8 +221,10 @@
|
||||
<ClCompile Include="Emu\DbgConsole.cpp" />
|
||||
<ClCompile Include="Emu\FS\VFS.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsDevice.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsDirBase.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsFile.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsFileBase.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsLocalDir.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsLocalFile.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsStream.cpp" />
|
||||
<ClCompile Include="Emu\FS\vfsStreamMemory.cpp" />
|
||||
|
@ -373,6 +373,12 @@
|
||||
<ClCompile Include="Emu\SysCalls\lv2\SC_Lwcond.cpp">
|
||||
<Filter>Emu\SysCalls\lv2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\FS\vfsDirBase.cpp">
|
||||
<Filter>Emu\FS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\FS\vfsLocalDir.cpp">
|
||||
<Filter>Emu\FS</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="rpcs3.rc" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user