mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
MaterialSystem: split off remaining texture streaming specific code
This should all be moved to the new file dedicated to texture streaming.
This commit is contained in:
parent
ca7b0d9981
commit
6d4de8c5b7
@ -18,6 +18,7 @@
|
||||
#include "windows/id3dx.h"
|
||||
#include "gameui/imgui_system.h"
|
||||
#include "materialsystem/cmaterialglue.h"
|
||||
#include "materialsystem/texturestreaming.h"
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
#include "materialsystem/cmaterialsystem.h"
|
||||
|
||||
@ -111,7 +112,7 @@ static void Mat_DumpStreamInfo_f(const CCommand& args)
|
||||
const char* const mode = args.ArgC() >= 2 ? args.Arg(1) : stream_overlay_mode->GetString();
|
||||
char* const scratch = stringBuf.get();
|
||||
|
||||
CMaterialSystem__GetStreamOverlay(mode, scratch, stringMem);
|
||||
TextureStreamMgr_GetStreamOverlay(mode, scratch, stringMem);
|
||||
Msg(eDLL_T::MS, "%s\n", scratch);
|
||||
}
|
||||
|
||||
|
@ -75,15 +75,9 @@ inline void(*CMaterialSystem__GetScreenSize)(CMaterialSystem* pMatSys, float* ou
|
||||
|
||||
inline void*(*v_DispatchDrawCall)(int64_t a1, uint64_t a2, int a3, int a4, int64_t a5, int a6, uint8_t a7, int64_t a8, uint32_t a9, uint32_t a10, int a11, __m128* a12, int a13, int64_t a14);
|
||||
inline ssize_t(*v_SpinPresent)(void);
|
||||
inline void(*CMaterialSystem__GetStreamOverlay)(const char* mode, char* buf, size_t bufSize);
|
||||
inline const char*(*CMaterialSystem__DrawStreamOverlay)(void* thisptr, uint8_t* a2, void* unused, void* a4);
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
inline ssize_t* g_nTotalStreamingTextureMemory = nullptr;
|
||||
inline ssize_t* g_nUnfreeStreamingTextureMemory = nullptr;
|
||||
inline ssize_t* g_nUnusableStreamingTextureMemory = nullptr;
|
||||
|
||||
inline void** s_pRenderContext; // NOTE: This is some CMaterial instance or array.
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
|
||||
@ -108,16 +102,11 @@ class VMaterialSystem : public IDetour
|
||||
LogFunAdr("CMaterialSystem::SwapBuffers", CMaterialSystem__SwapBuffers);
|
||||
LogFunAdr("CMaterialSystem::FindMaterialEx", CMaterialSystem__FindMaterialEx);
|
||||
LogFunAdr("CMaterialSystem::GetScreenSize", CMaterialSystem__GetScreenSize);
|
||||
LogFunAdr("CMaterialSystem::GetStreamOverlay", CMaterialSystem__GetStreamOverlay);
|
||||
LogFunAdr("CMaterialSystem::DrawStreamOverlay", CMaterialSystem__DrawStreamOverlay);
|
||||
LogFunAdr("DispatchDrawCall", v_DispatchDrawCall);
|
||||
LogFunAdr("SpinPresent", v_SpinPresent);
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
LogVarAdr("g_nTotalStreamingTextureMemory", g_nTotalStreamingTextureMemory);
|
||||
LogVarAdr("g_nUnfreeStreamingTextureMemory", g_nUnfreeStreamingTextureMemory);
|
||||
LogVarAdr("g_nUnusableStreamingTextureMemory", g_nUnusableStreamingTextureMemory);
|
||||
LogVarAdr("s_pRenderContext", s_pRenderContext);
|
||||
LogVarAdr("g_MaterialAdapterMgr", g_pMaterialAdapterMgr);
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
@ -135,8 +124,6 @@ class VMaterialSystem : public IDetour
|
||||
|
||||
g_GameDll.FindPatternSIMD("44 89 4C 24 ?? 44 88 44 24 ?? 48 89 4C 24 ??").GetPtr(CMaterialSystem__FindMaterialEx);
|
||||
g_GameDll.FindPatternSIMD("8B 05 ?? ?? ?? ?? 89 02 8B 05 ?? ?? ?? ?? 41 89 ?? C3 CC CC CC CC CC CC CC CC CC CC CC CC CC CC 8B 05 ?? ?? ?? ??").GetPtr(CMaterialSystem__GetScreenSize);
|
||||
g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 80 7C 24 ?? ?? 0F 84 ?? ?? ?? ?? 48 89 9C 24 ?? ?? ?? ??").FollowNearCallSelf().GetPtr(CMaterialSystem__GetStreamOverlay);
|
||||
g_GameDll.FindPatternSIMD("41 56 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 C6 02 ??").GetPtr(CMaterialSystem__DrawStreamOverlay);
|
||||
|
||||
g_GameDll.FindPatternSIMD("44 89 4C 24 ?? 44 89 44 24 ?? 48 89 4C 24 ?? 55 53 56").GetPtr(v_DispatchDrawCall);
|
||||
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 8B 15 ?? ?? ?? ??").GetPtr(v_SpinPresent);
|
||||
@ -145,10 +132,6 @@ class VMaterialSystem : public IDetour
|
||||
virtual void GetVar(void) const
|
||||
{
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
CMemory(CMaterialSystem__DrawStreamOverlay).Offset(0x1C).FindPatternSelf("48 8B 05", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(g_nTotalStreamingTextureMemory);
|
||||
CMemory(CMaterialSystem__DrawStreamOverlay).Offset(0x2D).FindPatternSelf("48 8B 05", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(g_nUnfreeStreamingTextureMemory);
|
||||
CMemory(CMaterialSystem__DrawStreamOverlay).Offset(0x50).FindPatternSelf("48 8B 05", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(g_nUnusableStreamingTextureMemory);
|
||||
|
||||
CMemory(v_DispatchDrawCall).FindPattern("48 8B ?? ?? ?? ?? 01").ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(s_pRenderContext);
|
||||
CMemory(CMaterialSystem__Disconnect).FindPattern("48 8D").ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(g_pMaterialAdapterMgr);
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
|
@ -105,8 +105,27 @@ struct TextureStreamMgr_s
|
||||
TextureAsset_s* streamableTextures[4];
|
||||
};
|
||||
|
||||
enum TextureStreamMemory_e
|
||||
{
|
||||
TML_TRACKER_UNFREE,
|
||||
|
||||
TML_TRACKER_UNKNOWN_1, // Appears unused by the retail runtime.
|
||||
TML_TRACKER_UNKNOWN_2, // Appears unused by the retail runtime.
|
||||
|
||||
TML_TRACKER_UNUSABE,
|
||||
|
||||
// Not a memory tracker!
|
||||
STREAMING_TEXTURES_MEMORY_LATENCY_FRAME_COUNT,
|
||||
};
|
||||
|
||||
inline void(*v_StreamDB_Init)(const char* const pszLevelName);
|
||||
|
||||
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);
|
||||
|
||||
inline ssize_t* g_textureStreamMemoryUsed = nullptr; // array size = STREAMING_TEXTURES_MEMORY_LATENCY_FRAME_COUNT.
|
||||
inline ssize_t* g_textureStreamMemoryTarget = nullptr; // pointer to single size var.
|
||||
|
||||
inline TextureStreamMgr_s* s_textureStreamMgr;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -115,14 +134,27 @@ class VTextureStreaming : public IDetour
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
LogFunAdr("StreamDB_Init", v_StreamDB_Init);
|
||||
|
||||
LogFunAdr("TextureStreamMgr_GetStreamOverlay", TextureStreamMgr_GetStreamOverlay);
|
||||
LogFunAdr("TextureStreamMgr_DrawStreamOverlayToInterface", TextureStreamMgr_DrawStreamOverlayToInterface);
|
||||
|
||||
LogVarAdr("g_textureStreamMemoryUsed", g_textureStreamMemoryUsed);
|
||||
LogVarAdr("g_textureStreamMemoryTarget", g_textureStreamMemoryTarget);
|
||||
|
||||
LogVarAdr("s_textureStreamMgr", s_textureStreamMgr);
|
||||
}
|
||||
virtual void GetFun(void) const
|
||||
{
|
||||
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 ?? ?? ?? ?? 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);
|
||||
}
|
||||
virtual void GetVar(void) const
|
||||
{
|
||||
CMemory(TextureStreamMgr_DrawStreamOverlayToInterface).Offset(0x2D).FindPatternSelf("48 8B 05", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(g_textureStreamMemoryUsed);
|
||||
CMemory(TextureStreamMgr_DrawStreamOverlayToInterface).Offset(0x1C).FindPatternSelf("48 8B 05", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(g_textureStreamMemoryTarget);
|
||||
|
||||
CMemory(v_StreamDB_Init).FindPattern("C6 05").ResolveRelativeAddressSelf(0x2, 0x7).GetPtr(s_textureStreamMgr);
|
||||
}
|
||||
virtual void GetCon(void) const
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <vgui/vgui_debugpanel.h>
|
||||
#include <vguimatsurface/MatSystemSurface.h>
|
||||
#include <materialsystem/cmaterialsystem.h>
|
||||
#include <materialsystem/texturestreaming.h>
|
||||
#ifndef CLIENT_DLL
|
||||
#include <engine/server/server.h>
|
||||
#endif // !CLIENT_DLL
|
||||
@ -288,7 +289,7 @@ void CTextOverlay::DrawGPUStats(void) const
|
||||
static const Color c = { 255, 255, 255, 255 };
|
||||
|
||||
DrawFormat(nWidth, nHeight, c, "%8zd/%8zd/%8zdkiB unusable/unfree/total GPU Streaming Texture memory\n",
|
||||
*g_nUnusableStreamingTextureMemory / 1024, *g_nUnfreeStreamingTextureMemory / 1024, *g_nTotalStreamingTextureMemory / 1024);
|
||||
g_textureStreamMemoryUsed[TML_TRACKER_UNUSABE] / 1024, g_textureStreamMemoryUsed[TML_TRACKER_UNFREE] / 1024, *g_textureStreamMemoryTarget / 1024);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -327,7 +328,7 @@ void CTextOverlay::DrawStreamOverlay(void) const
|
||||
static char szLogbuf[4096];
|
||||
static const Color c = { 255, 255, 255, 255 };
|
||||
|
||||
CMaterialSystem__GetStreamOverlay(stream_overlay_mode->GetString(), szLogbuf, sizeof(szLogbuf));
|
||||
TextureStreamMgr_GetStreamOverlay(stream_overlay_mode->GetString(), szLogbuf, sizeof(szLogbuf));
|
||||
CMatSystemSurface__DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, 20, 300, c.r(), c.g(), c.b(), c.a(), "%s", szLogbuf);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user