From 746660490bf65fccc473fe81f4fb02031b5c52e4 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:26:23 +0100 Subject: [PATCH] MaterialSystem: add more reversed types for texture streaming Reverse engineered. --- src/materialsystem/texturestreaming.h | 55 ++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/materialsystem/texturestreaming.h b/src/materialsystem/texturestreaming.h index cbf6206e..21e2f1d3 100644 --- a/src/materialsystem/texturestreaming.h +++ b/src/materialsystem/texturestreaming.h @@ -1,8 +1,59 @@ +//=============================================================================// +// +// Purpose: texture streaming and runtime management +// +//----------------------------------------------------------------------------- +// Some of these structs are based on the presentation held by the developer of +// the texture streaming system in Titanfall 2 and Apex Legends, see the links: +// - https://www.gdcvault.com/play/1024418/Efficient-Texture-Streaming-in-Titanfall +// - https://www.youtube.com/watch?v=q0aKNGH8WbA +//=============================================================================// + #ifndef TEXTURESTREAMING_H #define TEXTURESTREAMING_H #include "public/rtech/istreamdb.h" -inline void(*v_StreamDB_Init)(const char* const pszLevelName); +struct TextureStreamMgr_Task_s +{ + TextureAsset_t* textureAsset; + + // The mip level count to load or drop. + uint8 mipLevelCount; + char padding[3]; + + // The 'cost vs benefit' metric used to partially sort the task list to get + // the best and worst 16 textures. + float metric; +}; + +struct TextureStreamMgr_TaskList_s +{ + // STBSP async file handle and index to the current page. + int fileHandle; + int pageIndex; + + // Whether we should update the current page state. + bool updatePageState; + int padding; + + // Offset to the page in the STBSP to read up to size bytes. + uint64 pageOffset; + uint64 pageSize; + + // - loadBegin points to the first texture load task. + // - loadEnd points to the last texture load task. + // - loadLimit points to the absolute end of the load task buffer. + TextureStreamMgr_Task_s* loadBegin; + TextureStreamMgr_Task_s* loadEnd; + TextureStreamMgr_Task_s* loadLimit; + + // - dropBegin points to the first texture drop task. + // - dropEnd points to the last texture drop task. + // - dropLimit points to the absolute end of the drop task buffer. + TextureStreamMgr_Task_s* dropBegin; + TextureStreamMgr_Task_s* dropEnd; + TextureStreamMgr_Task_s* dropLimit; +}; struct TextureStreamMgr_s { @@ -39,6 +90,8 @@ struct TextureStreamMgr_s TextureAsset_t* streamableTextures[4]; }; +inline void(*v_StreamDB_Init)(const char* const pszLevelName); + inline TextureStreamMgr_s* s_textureStreamMgr; ///////////////////////////////////////////////////////////////////////////////