From 059f9fc82de70142d79debea1259cdb8ba7802b0 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 6 Jan 2025 00:53:54 +0100 Subject: [PATCH] RTech: move and rename texture streaming global state struct More correct names. --- src/materialsystem/texturestreaming.cpp | 2 +- src/materialsystem/texturestreaming.h | 41 +++++++++++++++++++++++-- src/public/rtech/istreamdb.h | 37 ---------------------- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/materialsystem/texturestreaming.cpp b/src/materialsystem/texturestreaming.cpp index 664f741a..ff6520e2 100644 --- a/src/materialsystem/texturestreaming.cpp +++ b/src/materialsystem/texturestreaming.cpp @@ -24,7 +24,7 @@ static void StreamDB_Init(const char* const pszLevelName) // If the requested STBSP file doesn't exist, then enable the GPU driven // texture streaming system. - const bool gpuDriven = s_streamDataBase->fileHandle == FS_ASYNC_FILE_INVALID; + const bool gpuDriven = s_textureStreamMgr->fileHandle == FS_ASYNC_FILE_INVALID; gpu_driven_tex_stream->SetValue(gpuDriven); if (!gpuDriven) diff --git a/src/materialsystem/texturestreaming.h b/src/materialsystem/texturestreaming.h index cdd665a8..cbf6206e 100644 --- a/src/materialsystem/texturestreaming.h +++ b/src/materialsystem/texturestreaming.h @@ -4,7 +4,42 @@ inline void(*v_StreamDB_Init)(const char* const pszLevelName); -inline StreamDB_s* s_streamDataBase; +struct TextureStreamMgr_s +{ + bool initialised; + bool hasResidentPages; + char filePath[260]; // size=MAX_PATH. + char gap_105[2]; + int fileHandle; // STBSP file handle. + char gap_10b[4]; + char* stringBuffer; + StreamDBHeader_s header; + ST_ResidentPage* residentPages; + MaterialGlue_t** materials; + ST_Material* materialInfo; + int64 maxResidentPageSize; + StreamingDBPageState_s pageStates[4]; + int picMip; + float streamBspBucketBias; + float streamBspDistScale; + __int64 unk_338; + uint32 streamBspCellX; + uint32 streamBspCellY; + int loadedLinkedTextureCount; + int totalMipLevelCount; + int loadedMipLevelCount; + int unk_34; + int64 usedStreamingMemory; + int64 totalStreamingMemory; + int unk_48; + int unk_50; + Vector3D streamBspCameraPos; + float streamBspHalfFovX; + float streamBspViewWidth; + TextureAsset_t* streamableTextures[4]; +}; + +inline TextureStreamMgr_s* s_textureStreamMgr; /////////////////////////////////////////////////////////////////////////////// class VTextureStreaming : public IDetour @@ -12,7 +47,7 @@ class VTextureStreaming : public IDetour virtual void GetAdr(void) const { LogFunAdr("StreamDB_Init", v_StreamDB_Init); - LogVarAdr("s_streamDataBase", s_streamDataBase); + LogVarAdr("s_textureStreamMgr", s_textureStreamMgr); } virtual void GetFun(void) const { @@ -20,7 +55,7 @@ class VTextureStreaming : public IDetour } virtual void GetVar(void) const { - CMemory(v_StreamDB_Init).FindPattern("C6 05").ResolveRelativeAddressSelf(0x2, 0x7).GetPtr(s_streamDataBase); + CMemory(v_StreamDB_Init).FindPattern("C6 05").ResolveRelativeAddressSelf(0x2, 0x7).GetPtr(s_textureStreamMgr); } virtual void GetCon(void) const { } diff --git a/src/public/rtech/istreamdb.h b/src/public/rtech/istreamdb.h index 458bce0b..7eb6dd63 100644 --- a/src/public/rtech/istreamdb.h +++ b/src/public/rtech/istreamdb.h @@ -59,41 +59,4 @@ struct ST_Material char unk2[8]; }; -// todo(amos): this is the texture streaming global state, -// rename it to TextureStreamMgr_s. -struct StreamDB_s -{ - bool initialised; - bool hasResidentPages; - char filePath[260]; // size=MAX_PATH. - char gap_105[2]; - int fileHandle; // STBSP file handle. - char gap_10b[4]; - char* stringBuffer; - StreamDBHeader_s header; - ST_ResidentPage* residentPages; - MaterialGlue_t** materials; - ST_Material* materialInfo; - int64 maxResidentPageSize; - StreamingDBPageState_s pageStates[4]; - int picMip; - float streamBspBucketBias; - float streamBspDistScale; - __int64 unk_338; - uint32 streamBspCellX; - uint32 streamBspCellY; - int loadedLinkedTextureCount; - int totalMipLevelCount; - int loadedMipLevelCount; - int unk_34; - int64 usedStreamingMemory; - int64 totalStreamingMemory; - int unk_48; - int unk_50; - Vector3D streamBspCameraPos; - float streamBspHalfFovX; - float streamBspViewWidth; - TextureAsset_t* streamableTextures[4]; -}; - #endif // RTECH_ISTREAMDB