mirror of https://github.com/AxioDL/metaforce.git
Deadlock fixes and PC TXTR loading
This commit is contained in:
parent
208049856b
commit
bc6ba1141d
|
@ -11,15 +11,6 @@ void ProjectResourceFactoryBase::Clear()
|
||||||
m_catalogNameToTag.clear();
|
m_catalogNameToTag.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
hecl::BlenderConnection& ProjectResourceFactoryBase::GetBackgroundBlender() const
|
|
||||||
{
|
|
||||||
std::experimental::optional<hecl::BlenderConnection>& shareConn =
|
|
||||||
((ProjectResourceFactoryBase*)this)->m_backgroundBlender;
|
|
||||||
if (!shareConn)
|
|
||||||
shareConn.emplace(hecl::VerbosityLevel);
|
|
||||||
return *shareConn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectResourceFactoryBase::ReadCatalog(const hecl::ProjectPath& catalogPath,
|
void ProjectResourceFactoryBase::ReadCatalog(const hecl::ProjectPath& catalogPath,
|
||||||
athena::io::YAMLDocWriter& nameWriter)
|
athena::io::YAMLDocWriter& nameWriter)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +31,7 @@ void ProjectResourceFactoryBase::ReadCatalog(const hecl::ProjectPath& catalogPat
|
||||||
hecl::ProjectPath path(m_proj->getProjectWorkingPath(), p.second->m_scalarString);
|
hecl::ProjectPath path(m_proj->getProjectWorkingPath(), p.second->m_scalarString);
|
||||||
if (path.getPathType() != hecl::ProjectPath::Type::File)
|
if (path.getPathType() != hecl::ProjectPath::Type::File)
|
||||||
continue;
|
continue;
|
||||||
SObjectTag pathTag = TagFromPath(path);
|
SObjectTag pathTag = TagFromPath(path, m_backgroundBlender);
|
||||||
if (pathTag)
|
if (pathTag)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
|
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
|
||||||
|
@ -119,7 +110,7 @@ void ProjectResourceFactoryBase::BackgroundIndexRecursiveProc(const hecl::Projec
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Classify intermediate into tag */
|
/* Classify intermediate into tag */
|
||||||
SObjectTag pathTag = TagFromPath(path);
|
SObjectTag pathTag = TagFromPath(path, m_backgroundBlender);
|
||||||
if (pathTag)
|
if (pathTag)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
|
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
|
||||||
|
@ -232,11 +223,7 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
|
||||||
nameWriter.finish();
|
nameWriter.finish();
|
||||||
fclose(nameFile);
|
fclose(nameFile);
|
||||||
|
|
||||||
if (m_backgroundBlender)
|
m_backgroundBlender.shutdown();
|
||||||
{
|
|
||||||
m_backgroundBlender->quitBlender();
|
|
||||||
m_backgroundBlender = std::experimental::nullopt;
|
|
||||||
}
|
|
||||||
Log.report(logvisor::Info, _S("Background index of '%s' complete; %d tags, %d names"),
|
Log.report(logvisor::Info, _S("Background index of '%s' complete; %d tags, %d names"),
|
||||||
m_origSpec->m_name, m_tagToPath.size(), m_catalogNameToTag.size());
|
m_origSpec->m_name, m_tagToPath.size(), m_catalogNameToTag.size());
|
||||||
m_backgroundRunning = false;
|
m_backgroundRunning = false;
|
||||||
|
@ -293,6 +280,16 @@ CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Last chance type validation */
|
||||||
|
urde::SObjectTag verifyTag = TagFromPath(path, hecl::SharedBlenderToken);
|
||||||
|
if (verifyTag.type != tag.type)
|
||||||
|
{
|
||||||
|
Log.report(logvisor::Error, _S("%s: expected type '%.4s', found '%.4s'"),
|
||||||
|
path.getRelativePath().c_str(),
|
||||||
|
tag.type.toString().c_str(), verifyTag.type.toString().c_str());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
/* Get cooked representation path */
|
/* Get cooked representation path */
|
||||||
hecl::ProjectPath cooked = GetCookedPath(path, true);
|
hecl::ProjectPath cooked = GetCookedPath(path, true);
|
||||||
|
|
||||||
|
@ -329,7 +326,8 @@ CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag,
|
||||||
return m_factoryMgr.MakeObject(tag, fr, paramXfer);
|
return m_factoryMgr.MakeObject(tag, fr, paramXfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const hecl::ProjectPath& path)
|
void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& tag,
|
||||||
|
const hecl::ProjectPath& path)
|
||||||
{
|
{
|
||||||
if (!m_workingPath)
|
if (!m_workingPath)
|
||||||
{
|
{
|
||||||
|
@ -339,7 +337,18 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const hecl::ProjectPath&
|
||||||
if (path.getPathType() != hecl::ProjectPath::Type::File)
|
if (path.getPathType() != hecl::ProjectPath::Type::File)
|
||||||
{
|
{
|
||||||
Log.report(logvisor::Error, _S("unable to find resource path '%s'"),
|
Log.report(logvisor::Error, _S("unable to find resource path '%s'"),
|
||||||
path.getAbsolutePath().c_str());
|
path.getRelativePath().c_str());
|
||||||
|
m_failed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Last chance type validation */
|
||||||
|
urde::SObjectTag verifyTag = m_parent.TagFromPath(path, hecl::SharedBlenderToken);
|
||||||
|
if (verifyTag.type != tag.type)
|
||||||
|
{
|
||||||
|
Log.report(logvisor::Error, _S("%s: expected type '%.4s', found '%.4s'"),
|
||||||
|
path.getRelativePath().c_str(),
|
||||||
|
tag.type.toString().c_str(), verifyTag.type.toString().c_str());
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -425,6 +434,7 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
|
||||||
else
|
else
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
lk.unlock();
|
||||||
|
|
||||||
return BuildSync(tag, search->second, paramXfer);
|
return BuildSync(tag, search->second, paramXfer);
|
||||||
}
|
}
|
||||||
|
@ -526,7 +536,8 @@ void ProjectResourceFactoryBase::AsyncIdle()
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
task.EnsurePath(search->second);
|
lk.unlock();
|
||||||
|
task.EnsurePath(task.x0_tag, search->second);
|
||||||
|
|
||||||
/* Pump load pipeline (cooking if needed) */
|
/* Pump load pipeline (cooking if needed) */
|
||||||
if (task.AsyncPump())
|
if (task.AsyncPump())
|
||||||
|
|
|
@ -29,7 +29,7 @@ protected:
|
||||||
std::unique_ptr<hecl::Database::IDataSpec> m_cookSpec;
|
std::unique_ptr<hecl::Database::IDataSpec> m_cookSpec;
|
||||||
urde::CFactoryMgr m_factoryMgr;
|
urde::CFactoryMgr m_factoryMgr;
|
||||||
|
|
||||||
std::experimental::optional<hecl::BlenderConnection> m_backgroundBlender;
|
hecl::BlenderToken m_backgroundBlender;
|
||||||
std::thread m_backgroundIndexTh;
|
std::thread m_backgroundIndexTh;
|
||||||
std::mutex m_backgroundIndexMutex;
|
std::mutex m_backgroundIndexMutex;
|
||||||
bool m_backgroundRunning = false;
|
bool m_backgroundRunning = false;
|
||||||
|
@ -56,15 +56,15 @@ protected:
|
||||||
IObj** ptr, const CVParamTransfer& xfer)
|
IObj** ptr, const CVParamTransfer& xfer)
|
||||||
: m_parent(parent), x0_tag(tag), xc_targetPtr(ptr), x18_cvXfer(xfer) {}
|
: m_parent(parent), x0_tag(tag), xc_targetPtr(ptr), x18_cvXfer(xfer) {}
|
||||||
|
|
||||||
void EnsurePath(const hecl::ProjectPath& path);
|
void EnsurePath(const urde::SObjectTag& tag,
|
||||||
|
const hecl::ProjectPath& path);
|
||||||
void CookComplete();
|
void CookComplete();
|
||||||
bool AsyncPump();
|
bool AsyncPump();
|
||||||
};
|
};
|
||||||
std::unordered_map<SObjectTag, AsyncTask> m_asyncLoadList;
|
std::unordered_map<SObjectTag, AsyncTask> m_asyncLoadList;
|
||||||
|
|
||||||
virtual SObjectTag TagFromPath(const hecl::ProjectPath& path) const=0;
|
virtual SObjectTag TagFromPath(const hecl::ProjectPath& path, hecl::BlenderToken& btok) const=0;
|
||||||
|
|
||||||
hecl::BlenderConnection& GetBackgroundBlender() const;
|
|
||||||
void ReadCatalog(const hecl::ProjectPath& catalogPath,
|
void ReadCatalog(const hecl::ProjectPath& catalogPath,
|
||||||
athena::io::YAMLDocWriter& nameWriter);
|
athena::io::YAMLDocWriter& nameWriter);
|
||||||
void BackgroundIndexRecursiveProc(const hecl::ProjectPath& path,
|
void BackgroundIndexRecursiveProc(const hecl::ProjectPath& path,
|
||||||
|
|
|
@ -36,11 +36,11 @@ void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj)
|
||||||
BeginBackgroundIndex(proj, DataSpec::SpecEntMP1, DataSpec::SpecEntMP1PC);
|
BeginBackgroundIndex(proj, DataSpec::SpecEntMP1, DataSpec::SpecEntMP1PC);
|
||||||
}
|
}
|
||||||
|
|
||||||
SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path) const
|
SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path, hecl::BlenderToken& btok) const
|
||||||
{
|
{
|
||||||
if (hecl::IsPathBlend(path))
|
if (hecl::IsPathBlend(path))
|
||||||
{
|
{
|
||||||
hecl::BlenderConnection& conn = GetBackgroundBlender();
|
hecl::BlenderConnection& conn = btok.getBlenderConnection();
|
||||||
if (!conn.openBlend(path))
|
if (!conn.openBlend(path))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class ProjectResourceFactoryMP1 : public ProjectResourceFactoryBase
|
||||||
public:
|
public:
|
||||||
ProjectResourceFactoryMP1(hecl::ClientProcess& clientProc);
|
ProjectResourceFactoryMP1(hecl::ClientProcess& clientProc);
|
||||||
void IndexMP1Resources(hecl::Database::Project& proj);
|
void IndexMP1Resources(hecl::Database::Project& proj);
|
||||||
SObjectTag TagFromPath(const hecl::ProjectPath& path) const;
|
SObjectTag TagFromPath(const hecl::ProjectPath& path, hecl::BlenderToken& btok) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ struct Application : boo::IApplicationCallback
|
||||||
void initialize(boo::IApplication* app)
|
void initialize(boo::IApplication* app)
|
||||||
{
|
{
|
||||||
zeus::detectCPU();
|
zeus::detectCPU();
|
||||||
|
//hecl::VerbosityLevel = 1;
|
||||||
|
|
||||||
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
|
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
|
||||||
Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
|
Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
|
||||||
|
|
|
@ -137,17 +137,18 @@ struct SClipScreenRect
|
||||||
|
|
||||||
enum class ETexelFormat
|
enum class ETexelFormat
|
||||||
{
|
{
|
||||||
I4 = 0,
|
I4 = 0,
|
||||||
I8 = 1,
|
I8 = 1,
|
||||||
IA4 = 2,
|
IA4 = 2,
|
||||||
IA8 = 3,
|
IA8 = 3,
|
||||||
C4 = 4,
|
C4 = 4,
|
||||||
C8 = 5,
|
C8 = 5,
|
||||||
C14X2 = 6,
|
C14X2 = 6,
|
||||||
RGB565 = 7,
|
RGB565 = 7,
|
||||||
RGB5A3 = 8,
|
RGB5A3 = 8,
|
||||||
RGBA8 = 9,
|
RGBA8 = 9,
|
||||||
CMPR = 10
|
CMPR = 10,
|
||||||
|
RGBA8PC = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGraphics
|
class CGraphics
|
||||||
|
|
|
@ -82,6 +82,7 @@ private:
|
||||||
void ProcessAnimation(const UVAnimation& anim);
|
void ProcessAnimation(const UVAnimation& anim);
|
||||||
void PadOutBuffer();
|
void PadOutBuffer();
|
||||||
void Update(const MaterialSet* matSet);
|
void Update(const MaterialSet* matSet);
|
||||||
|
operator bool() const {return m_buffer.size() != 0;}
|
||||||
} m_uvAnimBuffer;
|
} m_uvAnimBuffer;
|
||||||
|
|
||||||
/* urde addition: boo! */
|
/* urde addition: boo! */
|
||||||
|
|
|
@ -290,9 +290,12 @@ void CBooModel::UpdateUniformData() const
|
||||||
unskinnedXf.proj = CGraphics::GetPerspectiveProjectionMatrix();
|
unskinnedXf.proj = CGraphics::GetPerspectiveProjectionMatrix();
|
||||||
m_unskinnedXfBuffer->load(&unskinnedXf, sizeof(unskinnedXf));
|
m_unskinnedXfBuffer->load(&unskinnedXf, sizeof(unskinnedXf));
|
||||||
|
|
||||||
((CBooModel*)this)->m_uvAnimBuffer.Update(x4_matSet);
|
if (m_uvAnimBuffer)
|
||||||
m_uvMtxBuffer->load(m_uvAnimBuffer.m_buffer.data(),
|
{
|
||||||
m_uvAnimBuffer.m_buffer.size() * 64);
|
((CBooModel*)this)->m_uvAnimBuffer.Update(x4_matSet);
|
||||||
|
m_uvMtxBuffer->load(m_uvAnimBuffer.m_buffer.data(),
|
||||||
|
m_uvAnimBuffer.m_buffer.size() * 64);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooModel::DrawAlpha(const CModelFlags& flags) const
|
void CBooModel::DrawAlpha(const CModelFlags& flags) const
|
||||||
|
@ -331,7 +334,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store)
|
||||||
{
|
{
|
||||||
u32 version = hecl::SBig(*reinterpret_cast<u32*>(x0_data.get() + 0x4));
|
u32 version = hecl::SBig(*reinterpret_cast<u32*>(x0_data.get() + 0x4));
|
||||||
u32 flags = hecl::SBig(*reinterpret_cast<u32*>(x0_data.get() + 0x8));
|
u32 flags = hecl::SBig(*reinterpret_cast<u32*>(x0_data.get() + 0x8));
|
||||||
if (version != 16)
|
if (version != 0x10002)
|
||||||
Log.report(logvisor::Fatal, "invalid CMDL for loading with boo");
|
Log.report(logvisor::Fatal, "invalid CMDL for loading with boo");
|
||||||
|
|
||||||
u32 secCount = hecl::SBig(*reinterpret_cast<u32*>(x0_data.get() + 0x24));
|
u32 secCount = hecl::SBig(*reinterpret_cast<u32*>(x0_data.get() + 0x24));
|
||||||
|
@ -395,7 +398,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store)
|
||||||
surf.m_data.read(r);
|
surf.m_data.read(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float* aabbPtr = reinterpret_cast<const float*>(x0_data.get() + 0x18);
|
const float* aabbPtr = reinterpret_cast<const float*>(x0_data.get() + 0xc);
|
||||||
zeus::CAABox aabb(hecl::SBig(aabbPtr[0]), hecl::SBig(aabbPtr[1]), hecl::SBig(aabbPtr[2]),
|
zeus::CAABox aabb(hecl::SBig(aabbPtr[0]), hecl::SBig(aabbPtr[1]), hecl::SBig(aabbPtr[2]),
|
||||||
hecl::SBig(aabbPtr[3]), hecl::SBig(aabbPtr[4]), hecl::SBig(aabbPtr[5]));
|
hecl::SBig(aabbPtr[3]), hecl::SBig(aabbPtr[4]), hecl::SBig(aabbPtr[5]));
|
||||||
x28_modelInst = std::make_unique<CBooModel>(&x8_surfaces, x18_matSets[0],
|
x28_modelInst = std::make_unique<CBooModel>(&x8_surfaces, x18_matSets[0],
|
||||||
|
|
|
@ -34,6 +34,7 @@ class CTexture
|
||||||
void BuildRGB5A3FromGCN(CInputStream& in);
|
void BuildRGB5A3FromGCN(CInputStream& in);
|
||||||
void BuildRGBA8FromGCN(CInputStream& in);
|
void BuildRGBA8FromGCN(CInputStream& in);
|
||||||
void BuildDXT1FromGCN(CInputStream& in);
|
void BuildDXT1FromGCN(CInputStream& in);
|
||||||
|
void BuildRGBA8(CInputStream& in);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTexture(CInputStream& in);
|
CTexture(CInputStream& in);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
static logvisor::Module Log("urde::CTextureBoo");
|
||||||
|
|
||||||
/* GX uses this upsampling technique to prevent banding on downsampled texture formats */
|
/* GX uses this upsampling technique to prevent banding on downsampled texture formats */
|
||||||
static inline uint8_t Convert3To8(uint8_t v)
|
static inline uint8_t Convert3To8(uint8_t v)
|
||||||
|
@ -647,6 +648,19 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTexture::BuildRGBA8(CInputStream& in)
|
||||||
|
{
|
||||||
|
size_t texelCount = ComputeMippedTexelCount();
|
||||||
|
std::unique_ptr<atInt8[]> buf = in.readBytes(texelCount * 4);
|
||||||
|
|
||||||
|
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||||
|
{
|
||||||
|
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
|
||||||
|
buf.get(), texelCount * 4);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
CTexture::CTexture(CInputStream& in)
|
CTexture::CTexture(CInputStream& in)
|
||||||
{
|
{
|
||||||
x0_fmt = ETexelFormat(in.readUint32Big());
|
x0_fmt = ETexelFormat(in.readUint32Big());
|
||||||
|
@ -689,6 +703,11 @@ CTexture::CTexture(CInputStream& in)
|
||||||
case ETexelFormat::CMPR:
|
case ETexelFormat::CMPR:
|
||||||
BuildDXT1FromGCN(in);
|
BuildDXT1FromGCN(in);
|
||||||
break;
|
break;
|
||||||
|
case ETexelFormat::RGBA8PC:
|
||||||
|
BuildRGBA8(in);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.report(logvisor::Fatal, "invalid texture type %d for boo", int(x0_fmt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit d3c1e65900b309c3d4c805e99c03dd1fc91818bb
|
Subproject commit 51349be32ab052618e02a82a8e21b495b5b00432
|
Loading…
Reference in New Issue