MaterialSystem: rename CMaterialGlue member vars

This commit is contained in:
Kawe Mazidjatari 2024-01-24 23:39:57 +01:00
parent 8911bfa81a
commit 1410ecd79c
3 changed files with 97 additions and 83 deletions

View File

@ -519,7 +519,6 @@ void Pak_Decompress_f(const CCommand& args)
FileSystem()->Close(hPakFile);
PakFileHeader_t* pHeader = reinterpret_cast<PakFileHeader_t*>(pPakBuf);
uint16_t flags = (pHeader->flags[0] << 8) | pHeader->flags[1];
SYSTEMTIME systemTime;
FileTimeToSystemTime(&pHeader->fileTime, &systemTime);
@ -527,7 +526,7 @@ void Pak_Decompress_f(const CCommand& args)
Msg(eDLL_T::RTECH, " | |-+ Header ------------------------------------------------\n");
Msg(eDLL_T::RTECH, " | |-- Magic : '0x%08X'\n", pHeader->magic);
Msg(eDLL_T::RTECH, " | |-- Version : '%hu'\n", pHeader->version);
Msg(eDLL_T::RTECH, " | |-- Flags : '0x%04hX'\n", flags);
Msg(eDLL_T::RTECH, " | |-- Flags : '0x%04hX'\n", pHeader->flags);
Msg(eDLL_T::RTECH, " | |-- Time : '%hu-%hu-%hu/%hu %hu:%hu:%hu.%hu'\n",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wDayOfWeek,
systemTime.wHour, systemTime.wMinute, systemTime.wSecond, systemTime.wMilliseconds);
@ -544,7 +543,7 @@ void Pak_Decompress_f(const CCommand& args)
return;
}
if ((pHeader->flags[1] & 1) != 1)
if (!(pHeader->flags & PAK_HEADER_FLAGS_COMPRESSED))
{
Error(eDLL_T::RTECH, NO_ERROR, "%s - pak file '%s' already decompressed!\n",
__FUNCTION__, inPakFile.String());
@ -560,8 +559,10 @@ void Pak_Decompress_f(const CCommand& args)
return;
}
PakDecoder_t decoder{}; // Needs full decode mask as we don't decompress in chunks.
const uint64_t nDecompSize = Pak_InitDefaultDecoder(&decoder, pPakBuf, PAK_DECODE_MASK_FULL, nFileSize, NULL, sizeof(PakFileHeader_t));
const bool usesCustomCompression = pHeader->flags & PAK_HEADER_FLAGS_ZSTD;
PakDecoder_t decoder{};
const uint64_t nDecompSize = Pak_InitDecoder(&decoder, pPakBuf, UINT64_MAX, nFileSize, NULL, sizeof(PakFileHeader_t), usesCustomCompression);
if (nDecompSize != pHeader->decompressedSize)
{
@ -582,17 +583,17 @@ void Pak_Decompress_f(const CCommand& args)
uint8_t* const pDecompBuf = pDecompBufContainer.get();
// Needs full decode mask as we don't decompress in chunks.
decoder.outputMask = PAK_DECODE_MASK_FULL;
decoder.outputMask = UINT64_MAX;
decoder.outputBuf = pDecompBuf;
uint8_t nDecompResult = Pak_DefaultDecode(&decoder, pHeader->compressedSize, pHeader->decompressedSize);
uint8_t nDecompResult = Pak_StreamToBufferDecode(&decoder, pHeader->compressedSize, pHeader->decompressedSize, usesCustomCompression);
if (nDecompResult != 1)
{
Error(eDLL_T::RTECH, NO_ERROR, "%s - decompression failed for '%s' return value: '%hu'!\n",
__FUNCTION__, inPakFile.String(), nDecompResult);
}
pHeader->flags[1] = 0x0; // Set compressed flag to false for the decompressed pak file.
pHeader->flags &= ~PAK_HEADER_FLAGS_COMPRESSED; // Remove compressed flags.
pHeader->compressedSize = pHeader->decompressedSize; // Equal compressed size with decompressed.
FileSystem()->CreateDirHierarchy(PLATFORM_PAK_OVERRIDE_PATH, "GAME");
@ -1233,46 +1234,46 @@ void Mat_CrossHair_f(const CCommand& args)
Msg(eDLL_T::MS, "______________________________________________________________\n");
Msg(eDLL_T::MS, "-+ Material --------------------------------------------------\n");
Msg(eDLL_T::MS, " |-- ADDR: '%llX'\n", material);
Msg(eDLL_T::MS, " |-- GUID: '%llX'\n", material->m_GUID);
Msg(eDLL_T::MS, " |-- Streaming texture count: '%d'\n", material->m_nStreamableTextureCount);
Msg(eDLL_T::MS, " |-- Material width: '%d'\n", material->m_iWidth);
Msg(eDLL_T::MS, " |-- Material height: '%d'\n", material->m_iHeight);
Msg(eDLL_T::MS, " |-- Flags: '%llX'\n", material->m_iFlags);
Msg(eDLL_T::MS, " |-- GUID: '%llX'\n", material->assetGuid);
Msg(eDLL_T::MS, " |-- Num Streaming Textures: '%d'\n", material->numStreamingTextureHandles);
Msg(eDLL_T::MS, " |-- Material width: '%d'\n", material->width);
Msg(eDLL_T::MS, " |-- Material height: '%d'\n", material->height);
Msg(eDLL_T::MS, " |-- Samplers: '%08X'\n", material->samplers);
std::function<void(CMaterialGlue*, const char*)> fnPrintChild = [](CMaterialGlue* material, const char* print)
{
Msg(eDLL_T::MS, " |-+\n");
Msg(eDLL_T::MS, " | |-+ Child material ----------------------------------------\n");
Msg(eDLL_T::MS, print, material);
Msg(eDLL_T::MS, " | |-- GUID: '%llX'\n", material->m_GUID);
Msg(eDLL_T::MS, " | |-- Material name: '%s'\n", material->m_pszName);
Msg(eDLL_T::MS, " | |-- GUID: '%llX'\n", material->assetGuid);
Msg(eDLL_T::MS, " | |-- Material name: '%s'\n", material->name);
};
Msg(eDLL_T::MS, " |-- Material name: '%s'\n", material->m_pszName);
Msg(eDLL_T::MS, " |-- Material surface name 1: '%s'\n", material->m_pszSurfaceProp);
Msg(eDLL_T::MS, " |-- Material surface name 2: '%s'\n", material->m_pszSurfaceProp2);
Msg(eDLL_T::MS, " |-- DX buffer: '%llX'\n", material->m_pDXBuffer);
Msg(eDLL_T::MS, " |-- DX buffer VFTable: '%llX'\n", material->m_pID3D11BufferVTable);
Msg(eDLL_T::MS, " |-- Material name: '%s'\n", material->name);
Msg(eDLL_T::MS, " |-- Material surface name 1: '%s'\n", material->surfaceProp);
Msg(eDLL_T::MS, " |-- Material surface name 2: '%s'\n", material->surfaceProp2);
Msg(eDLL_T::MS, " |-- DX buffer: '%llX'\n", material->dxBuffer);
Msg(eDLL_T::MS, " |-- DX buffer VFTable: '%llX'\n", material->unkD3DPointer);
material->m_pDepthShadow
? fnPrintChild(material->m_pDepthShadow, " | |-+ DepthShadow: '%llX'\n")
material->depthShadowMaterial
? fnPrintChild(material->depthShadowMaterial, " | |-+ DepthShadow: '%llX'\n")
: Msg(eDLL_T::MS, " | |-+ DepthShadow: 'NULL'\n");
material->m_pDepthPrepass
? fnPrintChild(material->m_pDepthPrepass, " | |-+ DepthPrepass: '%llX'\n")
material->depthPrepassMaterial
? fnPrintChild(material->depthPrepassMaterial, " | |-+ DepthPrepass: '%llX'\n")
: Msg(eDLL_T::MS, " | |-+ DepthPrepass: 'NULL'\n");
material->m_pDepthVSM
? fnPrintChild(material->m_pDepthVSM, " | |-+ DepthVSM: '%llX'\n")
material->depthVSMMaterial
? fnPrintChild(material->depthVSMMaterial, " | |-+ DepthVSM: '%llX'\n")
: Msg(eDLL_T::MS, " | |-+ DepthVSM: 'NULL'\n");
material->m_pDepthShadow
? fnPrintChild(material->m_pDepthShadow, " | |-+ DepthShadowTight: '%llX'\n")
material->depthShadowTightMaterial
? fnPrintChild(material->depthShadowTightMaterial, " | |-+ DepthShadowTight: '%llX'\n")
: Msg(eDLL_T::MS, " | |-+ DepthShadowTight: 'NULL'\n");
material->m_pColPass
? fnPrintChild(material->m_pColPass, " | |-+ ColPass: '%llX'\n")
material->colpassMaterial
? fnPrintChild(material->colpassMaterial, " | |-+ ColPass: '%llX'\n")
: Msg(eDLL_T::MS, " | |-+ ColPass: 'NULL'\n");
Msg(eDLL_T::MS, "-+ Texture GUID map ------------------------------------------\n");
Msg(eDLL_T::MS, " |-- Texture handles: '%llX'\n", material->m_pTextureHandles);
Msg(eDLL_T::MS, " |-- Streaming texture handles: '%llX'\n", material->m_pStreamableTextureHandles);
Msg(eDLL_T::MS, " |-- Texture handles: '%llX'\n", material->textureHandles);
Msg(eDLL_T::MS, " |-- Streaming texture handles: '%llX'\n", material->streamingTextureHandles);
Msg(eDLL_T::MS, "--------------------------------------------------------------\n");
}

View File

@ -5,59 +5,72 @@
#include "public/materialsystem/shader_vcs_version.h"
#include "public/rendersystem/schema/texture.g.h"
struct CMaterialGlue_Unknown
struct MaterialDXState_t
{
__m128i unk1;
__m128i unk2;
__m128i unk3;
uint32_t blendState[8];
unsigned int unkFlags;
unsigned __int16 depthStencilFlags;
unsigned __int16 rasterizerFlags;
char pad[8];
};
#pragma pack(push, 1) // Without this MSVC might get the idea to align our members to completely fuck the offsets up.
// [ PIXIE ]: The texture GUID's aren't in a specific order, gonna leave them as ptr's so an individual can check them in any memory searcher.
// [ PIXIE ]: Verification needed for earlier seasons, if the struct is the same.
// [ PIXIE ]: Class seems mostly right, a few members are still missing though.
#pragma pack(push, 1)
class CMaterialGlue : public IMaterialInternal
{
public:
uint8_t pad_0008[8]; //0x0008
uint64_t m_GUID; //0x0010
const char* m_pszName; //0x0018
const char* m_pszSurfaceProp; //0x0020
const char* m_pszSurfaceProp2; //0x0028
CMaterialGlue* m_pDepthShadow; //0x0030
CMaterialGlue* m_pDepthPrepass; //0x0038
CMaterialGlue* m_pDepthVSM; //0x0040
CMaterialGlue* m_pDepthShadowTight; //0x0048
CMaterialGlue* m_pColPass; //0x0050
CShaderGlue* m_pShaderGlue; //0x0058
TextureHeader_t** m_pTextureHandles; //0x0060
TextureHeader_t** m_pStreamableTextureHandles; //0x0068
int16_t m_nStreamableTextureCount; //0x0070
int16_t m_iWidth; //0x0072
int16_t m_iHeight; //0x0074
int16_t m_iDepth; //0x0076
uint32_t m_iFlags; //0x0078 [ PIXIE ]: I'm pretty sure those are VTF Image Flags, If you set them to NULL they cause Texture stretching.
int32_t m_unused2; //0x007C
uint8_t pad_0080[8]; //0x0080
uint32_t m_iUnknownFlags1; //0x0088
char pad_008C[4]; //0x008C
CMaterialGlue_Unknown m_UnkSections[2];
uint8_t bytef0;
uint8_t bytef1;
uint8_t m_iMaterialType;
uint64_t assetGuid; //0x0010
const char* name; //0x0018
const char* surfaceProp; //0x0020
const char* surfaceProp2; //0x0028
CMaterialGlue* depthShadowMaterial; //0x0030
CMaterialGlue* depthPrepassMaterial; //0x0038
CMaterialGlue* depthVSMMaterial; //0x0040
CMaterialGlue* depthShadowTightMaterial; //0x0048
CMaterialGlue* colpassMaterial; //0x0050
CShaderGlue* shaderset; //0x0058
TextureHeader_t** textureHandles; //0x0060
TextureHeader_t** streamingTextureHandles; //0x0068
int16_t numStreamingTextureHandles; //0x0070
int16_t width; //0x0072
int16_t height; //0x0074
int16_t depth; //0x0076
uint32_t samplers; //0x0078
char padding_7C[4]; //0x007C
uint32_t unk_80;
uint32_t unk_84;
uint64_t flags; // 0x0088
MaterialDXState_t dxStates[2];
uint16_t numAnimationFrames; // used in CMaterialGlue::GetNumAnimationFrames (0x1403B4250), which is called from GetSpriteInfo @ 0x1402561FC
uint8_t materialType;
uint8_t bytef3;
int dwordf4;
void* m_pTextureAnim;
void** m_pDXBuffer;
void** m_pID3D11BufferVTable;
void* m_pViewsBuffer;
uint32_t m_iUnknown3; //0x0118
uint16_t m_iUnknown4; //0x011C
uint16_t m_iUnknown5; //0x011E
uint16_t m_iUnknown6; //0x0120
uint64_t m_Unknown7; //0x0122
uint32_t m_iUnknown8; //0x012A
uint16_t m_iUnknown9; //0x012E
char padding_F4[4];
void* textureAnim;
void** dxBuffer;
void** unkD3DPointer; // was m_pID3D11BufferVTable
void* viewsBuffer;
uint32_t unknown3; //0x0118
uint16_t unknown4; //0x011C
uint16_t unknown5; //0x011E
uint16_t unknown6; //0x0120
uint64_t unknown7; //0x0122
uint32_t unknown8; //0x012A
uint16_t unknown9; //0x012E
}; //Size: 0x0130 confirmed end size.
static_assert(sizeof(CMaterialGlue) == 0x130);
#pragma pack(pop)

View File

@ -229,12 +229,12 @@ void CTextOverlay::DrawCrosshairMaterial(void) const
static Color c = { 255, 255, 255, 255 };
DrawFormat(cl_materialinfo_offset_x->GetInt(), cl_materialinfo_offset_y->GetInt(), c, "name: %s\nguid: %llx\ndimensions: %d x %d\nsurface: %s/%s\nstc: %i\ntc: %i",
pMaterialGlue->m_pszName,
pMaterialGlue->m_GUID,
pMaterialGlue->m_iWidth, pMaterialGlue->m_iHeight,
pMaterialGlue->m_pszSurfaceProp, pMaterialGlue->m_pszSurfaceProp2,
pMaterialGlue->m_nStreamableTextureCount,
pMaterialGlue->m_pShaderGlue->m_nTextureInputCount);
pMaterialGlue->name,
pMaterialGlue->assetGuid,
pMaterialGlue->width, pMaterialGlue->height,
pMaterialGlue->surfaceProp, pMaterialGlue->surfaceProp2,
pMaterialGlue->numStreamingTextureHandles,
pMaterialGlue->shaderset->m_nTextureInputCount);
}
//-----------------------------------------------------------------------------