2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 20:27:42 +00:00

Deadlock fixes and PC TXTR loading

This commit is contained in:
Jack Andersen
2016-03-31 11:06:41 -10:00
parent 208049856b
commit bc6ba1141d
11 changed files with 80 additions and 43 deletions

View File

@@ -137,17 +137,18 @@ struct SClipScreenRect
enum class ETexelFormat
{
I4 = 0,
I8 = 1,
IA4 = 2,
IA8 = 3,
C4 = 4,
C8 = 5,
C14X2 = 6,
RGB565 = 7,
RGB5A3 = 8,
RGBA8 = 9,
CMPR = 10
I4 = 0,
I8 = 1,
IA4 = 2,
IA8 = 3,
C4 = 4,
C8 = 5,
C14X2 = 6,
RGB565 = 7,
RGB5A3 = 8,
RGBA8 = 9,
CMPR = 10,
RGBA8PC = 16
};
class CGraphics

View File

@@ -82,6 +82,7 @@ private:
void ProcessAnimation(const UVAnimation& anim);
void PadOutBuffer();
void Update(const MaterialSet* matSet);
operator bool() const {return m_buffer.size() != 0;}
} m_uvAnimBuffer;
/* urde addition: boo! */

View File

@@ -290,9 +290,12 @@ void CBooModel::UpdateUniformData() const
unskinnedXf.proj = CGraphics::GetPerspectiveProjectionMatrix();
m_unskinnedXfBuffer->load(&unskinnedXf, sizeof(unskinnedXf));
((CBooModel*)this)->m_uvAnimBuffer.Update(x4_matSet);
m_uvMtxBuffer->load(m_uvAnimBuffer.m_buffer.data(),
m_uvAnimBuffer.m_buffer.size() * 64);
if (m_uvAnimBuffer)
{
((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
@@ -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 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");
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);
}
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]),
hecl::SBig(aabbPtr[3]), hecl::SBig(aabbPtr[4]), hecl::SBig(aabbPtr[5]));
x28_modelInst = std::make_unique<CBooModel>(&x8_surfaces, x18_matSets[0],

View File

@@ -34,6 +34,7 @@ class CTexture
void BuildRGB5A3FromGCN(CInputStream& in);
void BuildRGBA8FromGCN(CInputStream& in);
void BuildDXT1FromGCN(CInputStream& in);
void BuildRGBA8(CInputStream& in);
public:
CTexture(CInputStream& in);

View File

@@ -5,6 +5,7 @@
namespace urde
{
static logvisor::Module Log("urde::CTextureBoo");
/* GX uses this upsampling technique to prevent banding on downsampled texture formats */
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)
{
x0_fmt = ETexelFormat(in.readUint32Big());
@@ -689,6 +703,11 @@ CTexture::CTexture(CInputStream& in)
case ETexelFormat::CMPR:
BuildDXT1FromGCN(in);
break;
case ETexelFormat::RGBA8PC:
BuildRGBA8(in);
break;
default:
Log.report(logvisor::Fatal, "invalid texture type %d for boo", int(x0_fmt));
}
}