Implemented vfsLocalDir & vfsDirBase.

Improved ThreadBase.
Minor fixes.
This commit is contained in:
DH 2014-02-02 21:42:32 +02:00
parent 16c284214f
commit beb19633e9
16 changed files with 187 additions and 53 deletions

View File

@ -34,12 +34,12 @@ public:
struct ID struct ID
{ {
wxString m_name; std::string m_name;
u8 m_attr; u8 m_attr;
IDData* m_data; IDData* m_data;
template<typename T> 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_name(name)
, m_attr(attr) , m_attr(attr)
{ {
@ -58,8 +58,6 @@ struct ID
class IdManager class IdManager
{ {
ArrayF<ID> IDs;
static const ID_TYPE s_first_id = 1; static const ID_TYPE s_first_id = 1;
static const ID_TYPE s_max_id = -1; static const ID_TYPE s_max_id = -1;
@ -99,7 +97,7 @@ public:
} }
template<typename T> 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); std::lock_guard<std::mutex> lock(m_mtx_main);

View File

@ -1,29 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Thread.h" #include "Thread.h"
static DWORD g_tls_this_thread = 0xFFFFFFFF; __declspec(thread) NamedThreadBase* g_tls_this_thread = nullptr;
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;
NamedThreadBase* GetCurrentNamedThread() NamedThreadBase* GetCurrentNamedThread()
{ {
return (NamedThreadBase*)::TlsGetValue(g_tls_this_thread); return g_tls_this_thread;
} }
std::string NamedThreadBase::GetThreadName() const std::string NamedThreadBase::GetThreadName() const
@ -62,7 +44,7 @@ void ThreadBase::Start()
m_executor = new std::thread( m_executor = new std::thread(
[this]() [this]()
{ {
::TlsSetValue(g_tls_this_thread, this); g_tls_this_thread = this;
Task(); Task();
@ -130,7 +112,7 @@ thread::thread()
void thread::start(std::function<void()> func) 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() void thread::detach()

View File

@ -109,7 +109,7 @@ protected:
CPUThread(CPUThreadType type); CPUThread(CPUThreadType type);
public: public:
~CPUThread(); virtual ~CPUThread();
u32 m_wait_thread_id; u32 m_wait_thread_id;

View File

@ -20,7 +20,6 @@ PPCThread::PPCThread(CPUThreadType type) : CPUThread(type)
PPCThread::~PPCThread() PPCThread::~PPCThread()
{ {
Close();
} }
void PPCThread::DoReset() void PPCThread::DoReset()

View File

@ -24,7 +24,7 @@ protected:
PPCThread(CPUThreadType type); PPCThread(CPUThreadType type);
public: public:
~PPCThread(); virtual ~PPCThread();
protected: protected:
virtual void DoReset() override; virtual void DoReset() override;

View File

@ -22,7 +22,6 @@ PPUThread::PPUThread() : PPCThread(CPU_THREAD_PPU)
PPUThread::~PPUThread() PPUThread::~PPUThread()
{ {
//~PPCThread();
} }
void PPUThread::DoReset() void PPUThread::DoReset()

View File

@ -370,14 +370,14 @@ struct PPCdouble
case _FPCLASS_PINF: return FPR_PINF; case _FPCLASS_PINF: return FPR_PINF;
} }
#else #else
switch (fpc) switch (fpc)
{ {
case FP_NAN: return FPR_QNAN; case FP_NAN: return FPR_QNAN;
case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF; case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF;
case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD; case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD;
case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ; case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ;
default: return signbit(_double) ? FPR_NN : FPR_PN; default: return signbit(_double) ? FPR_NN : FPR_PN;
} }
#endif #endif
throw wxString::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc); throw wxString::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc);
@ -609,7 +609,7 @@ public:
public: public:
PPUThread(); PPUThread();
~PPUThread(); virtual ~PPUThread();
inline u8 GetCR(const u8 n) const inline u8 GetCR(const u8 n) const
{ {

View File

@ -50,7 +50,7 @@ class RawSPUThread
public: public:
RawSPUThread(u32 index, CPUThreadType type = CPU_THREAD_RAW_SPU); RawSPUThread(u32 index, CPUThreadType type = CPU_THREAD_RAW_SPU);
~RawSPUThread(); virtual ~RawSPUThread();
virtual bool Read8(const u64 addr, u8* value) override; virtual bool Read8(const u64 addr, u8* value) override;
virtual bool Read16(const u64 addr, u16* value) override; virtual bool Read16(const u64 addr, u16* value) override;

View File

@ -698,7 +698,7 @@ public:
public: public:
SPUThread(CPUThreadType type = CPU_THREAD_SPU); SPUThread(CPUThreadType type = CPU_THREAD_SPU);
~SPUThread(); virtual ~SPUThread();
virtual wxString RegsToString() virtual wxString RegsToString()
{ {

View File

@ -1,3 +1,44 @@
#include "stdafx.h" #include "stdafx.h"
#include "vfsDirBase.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;
}

View File

@ -1,19 +1,51 @@
#pragma once #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 class vfsDirBase
{ {
virtual bool Open(const wxString& path)=0; protected:
virtual Array<DirInfo> GetEntryes()=0; wxString m_cwd;
virtual void Close()=0; 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 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 Rename(const wxString& from, const wxString& to)=0;
virtual bool Remove(const wxString& path)=0; virtual bool Remove(const wxString& path)=0;
}; };

View 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);
}

View 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;
};

View File

@ -133,10 +133,11 @@ std::string GLFragmentDecompilerThread::AddCond(int fp16)
std::string GLFragmentDecompilerThread::AddConst() std::string GLFragmentDecompilerThread::AddConst()
{ {
if(m_parr.HasParam(PARAM_UNIFORM, "vec4", 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 std::string("fc") + std::to_string(m_size + 4 * 4); {
} return name;
}
mem32_ptr_t data(m_addr + m_size + m_offset); mem32_ptr_t data(m_addr + m_size + m_offset);
@ -145,7 +146,7 @@ std::string GLFragmentDecompilerThread::AddConst()
u32 y = GetData(data[1]); u32 y = GetData(data[1]);
u32 z = GetData(data[2]); u32 z = GetData(data[2]);
u32 w = GetData(data[3]); 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::string("vec4(") + std::to_string((float&)x) + ", " + std::to_string((float&)y)
+ ", " + std::to_string((float&)z) + ", " + std::to_string((float&)w) + ")"); + ", " + std::to_string((float&)z) + ", " + std::to_string((float&)w) + ")");
} }

View File

@ -221,8 +221,10 @@
<ClCompile Include="Emu\DbgConsole.cpp" /> <ClCompile Include="Emu\DbgConsole.cpp" />
<ClCompile Include="Emu\FS\VFS.cpp" /> <ClCompile Include="Emu\FS\VFS.cpp" />
<ClCompile Include="Emu\FS\vfsDevice.cpp" /> <ClCompile Include="Emu\FS\vfsDevice.cpp" />
<ClCompile Include="Emu\FS\vfsDirBase.cpp" />
<ClCompile Include="Emu\FS\vfsFile.cpp" /> <ClCompile Include="Emu\FS\vfsFile.cpp" />
<ClCompile Include="Emu\FS\vfsFileBase.cpp" /> <ClCompile Include="Emu\FS\vfsFileBase.cpp" />
<ClCompile Include="Emu\FS\vfsLocalDir.cpp" />
<ClCompile Include="Emu\FS\vfsLocalFile.cpp" /> <ClCompile Include="Emu\FS\vfsLocalFile.cpp" />
<ClCompile Include="Emu\FS\vfsStream.cpp" /> <ClCompile Include="Emu\FS\vfsStream.cpp" />
<ClCompile Include="Emu\FS\vfsStreamMemory.cpp" /> <ClCompile Include="Emu\FS\vfsStreamMemory.cpp" />

View File

@ -373,6 +373,12 @@
<ClCompile Include="Emu\SysCalls\lv2\SC_Lwcond.cpp"> <ClCompile Include="Emu\SysCalls\lv2\SC_Lwcond.cpp">
<Filter>Emu\SysCalls\lv2</Filter> <Filter>Emu\SysCalls\lv2</Filter>
</ClCompile> </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>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="rpcs3.rc" /> <ResourceCompile Include="rpcs3.rc" />