MaterialSystem: only run world texture crediting if we aren't GPU driven

This code credits textures based on the STBSP column we are in. However, the GPU driven texture streaming system has its own logic for this. Don't run the STBSP world texture crediting code if the GPU driven system is enabled to save on runtime overhead and possible interference.
This commit is contained in:
Kawe Mazidjatari 2025-01-07 11:38:53 +01:00
parent 37e3c8c653
commit 164c594486
2 changed files with 39 additions and 0 deletions

View File

@ -31,7 +31,39 @@ static void StreamDB_Init(const char* const pszLevelName)
Msg(eDLL_T::MS, "StreamDB_Init: Loaded STBSP file '%s.stbsp'\n", targetStreamDB);
}
//---------------------------------------------------------------------------------
// Purpose: shift and scale the texture's histogram to accommodate varying screen
// FOV, screen resolutions and texture resolutions.
// Input : *taskList -
//---------------------------------------------------------------------------------
static void StreamDB_CreditWorldTextures(TextureStreamMgr_TaskList_s* const taskList)
{
// If we use the GPU driven texture streaming system, do not credit the textures
// based on the STBSP pages.
if (gpu_driven_tex_stream->GetBool())
return;
v_StreamDB_CreditWorldTextures(taskList);
}
//---------------------------------------------------------------------------------
// Purpose: same as above, except for older (legacy) STBSP's (v8.0).
// Input : *taskList -
//---------------------------------------------------------------------------------
static void StreamDB_CreditWorldTextures_Legacy(TextureStreamMgr_TaskList_s* const taskList)
{
// If we use the GPU driven texture streaming system, do not credit the textures
// based on the STBSP pages.
if (gpu_driven_tex_stream->GetBool())
return;
v_StreamDB_CreditWorldTextures_Legacy(taskList);
}
void VTextureStreaming::Detour(const bool bAttach) const
{
DetourSetup(&v_StreamDB_Init, &StreamDB_Init, bAttach);
DetourSetup(&v_StreamDB_CreditWorldTextures, &StreamDB_CreditWorldTextures, bAttach);
DetourSetup(&v_StreamDB_CreditWorldTextures_Legacy, &StreamDB_CreditWorldTextures_Legacy, bAttach);
}

View File

@ -119,6 +119,8 @@ enum TextureStreamMemory_e
};
inline void(*v_StreamDB_Init)(const char* const pszLevelName);
inline void(*v_StreamDB_CreditWorldTextures)(TextureStreamMgr_TaskList_s* const taskList);
inline void(*v_StreamDB_CreditWorldTextures_Legacy)(TextureStreamMgr_TaskList_s* const taskList);
inline void(*TextureStreamMgr_GetStreamOverlay)(const char* const mode, char* const buf, const size_t bufSize);
inline const char* (*TextureStreamMgr_DrawStreamOverlayToInterface)(void* thisptr, uint8_t* a2, void* unused, void* debugOverlayIface);
@ -134,6 +136,8 @@ class VTextureStreaming : public IDetour
virtual void GetAdr(void) const
{
LogFunAdr("StreamDB_Init", v_StreamDB_Init);
LogFunAdr("StreamDB_CreditWorldTextures", v_StreamDB_CreditWorldTextures);
LogFunAdr("StreamDB_CreditWorldTextures_Legacy", v_StreamDB_CreditWorldTextures_Legacy);
LogFunAdr("TextureStreamMgr_GetStreamOverlay", TextureStreamMgr_GetStreamOverlay);
LogFunAdr("TextureStreamMgr_DrawStreamOverlayToInterface", TextureStreamMgr_DrawStreamOverlayToInterface);
@ -147,6 +151,9 @@ class VTextureStreaming : public IDetour
{
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 54 41 56 41 57 48 83 EC 40 48 8B E9").GetPtr(v_StreamDB_Init);
g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? EB ?? 48 8B CF E8 ?? ?? ?? ?? 4C 8D 25").FollowNearCallSelf().GetPtr(v_StreamDB_CreditWorldTextures);
g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 4C 8D 25 ?? ?? ?? ?? 4C 89 64 24").FollowNearCallSelf().GetPtr(v_StreamDB_CreditWorldTextures_Legacy);
g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 80 7C 24 ?? ?? 0F 84 ?? ?? ?? ?? 48 89 9C 24 ?? ?? ?? ??").FollowNearCallSelf().GetPtr(TextureStreamMgr_GetStreamOverlay);
g_GameDll.FindPatternSIMD("41 56 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 C6 02 ??").GetPtr(TextureStreamMgr_DrawStreamOverlayToInterface);
}