mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
MaterialSystem: correctly define 'CMaterialGlue'
Remove structure packing (not needed), and properly lay it out. The material glue class is a wrapper around the actual material struct, which is what has been seperated out in this path. The material struct also contains more newly reversed members.
This commit is contained in:
parent
4445edac6d
commit
37e3c8c653
@ -287,50 +287,48 @@ Mat_CrossHair_f
|
||||
Print the material under the crosshair.
|
||||
=====================
|
||||
*/
|
||||
static void PrintChildMat(const CMaterialGlue* const materialGlue, const char* const text)
|
||||
{
|
||||
Msg(eDLL_T::MS, " |-+\n");
|
||||
Msg(eDLL_T::MS, " | |-+ Child material ----------------------------------------\n");
|
||||
Msg(eDLL_T::MS, text, materialGlue);
|
||||
|
||||
if (materialGlue)
|
||||
{
|
||||
const MaterialGlue_s* const material = materialGlue->Get();
|
||||
|
||||
Msg(eDLL_T::MS, " | |-- Pak GUID: '%llX'\n", material->guid);
|
||||
Msg(eDLL_T::MS, " | |-- Material name: '%s'\n", material->name);
|
||||
}
|
||||
}
|
||||
|
||||
void Mat_CrossHair_f(const CCommand& args)
|
||||
{
|
||||
CMaterialGlue* material = v_GetMaterialAtCrossHair();
|
||||
const CMaterialGlue* const materialGlue = v_GetMaterialAtCrossHair();
|
||||
const MaterialGlue_s* const material = materialGlue->Get();
|
||||
|
||||
if (material)
|
||||
{
|
||||
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->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->assetGuid);
|
||||
Msg(eDLL_T::MS, " | |-- Material name: '%s'\n", material->name);
|
||||
};
|
||||
Msg(eDLL_T::MS, " |-- Address: '%llX'\n", material);
|
||||
Msg(eDLL_T::MS, " |-- Pak GUID: '%llX'\n", material->guid);
|
||||
Msg(eDLL_T::MS, " |-- Samplers: '%08X'\n", *(uint32*)material->samplers);
|
||||
Msg(eDLL_T::MS, " |-- Streaming handles: '%hu'\n", material->streamingTextureHandleCount);
|
||||
Msg(eDLL_T::MS, " |-- Material width: '%hu'\n", material->width);
|
||||
Msg(eDLL_T::MS, " |-- Material height: '%hu'\n", material->height);
|
||||
|
||||
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);
|
||||
Msg(eDLL_T::MS, " |-- Uber buffer: '%llX'\n", material->uberBuffer);
|
||||
Msg(eDLL_T::MS, " |-- View buffer: '%llX'\n", material->viewBuffer);
|
||||
|
||||
material->depthShadowMaterial
|
||||
? fnPrintChild(material->depthShadowMaterial, " | |-+ DepthShadow: '%llX'\n")
|
||||
: Msg(eDLL_T::MS, " | |-+ DepthShadow: 'NULL'\n");
|
||||
material->depthPrepassMaterial
|
||||
? fnPrintChild(material->depthPrepassMaterial, " | |-+ DepthPrepass: '%llX'\n")
|
||||
: Msg(eDLL_T::MS, " | |-+ DepthPrepass: 'NULL'\n");
|
||||
material->depthVSMMaterial
|
||||
? fnPrintChild(material->depthVSMMaterial, " | |-+ DepthVSM: '%llX'\n")
|
||||
: Msg(eDLL_T::MS, " | |-+ DepthVSM: 'NULL'\n");
|
||||
material->depthShadowTightMaterial
|
||||
? fnPrintChild(material->depthShadowTightMaterial, " | |-+ DepthShadowTight: '%llX'\n")
|
||||
: Msg(eDLL_T::MS, " | |-+ DepthShadowTight: 'NULL'\n");
|
||||
material->colpassMaterial
|
||||
? fnPrintChild(material->colpassMaterial, " | |-+ ColPass: '%llX'\n")
|
||||
: Msg(eDLL_T::MS, " | |-+ ColPass: 'NULL'\n");
|
||||
PrintChildMat(material->depthMaterials[DEPTH_SHADOW], " | |-+ Depth shadow: '%llX'\n");
|
||||
PrintChildMat(material->depthMaterials[DEPTH_PREPASS], " | |-+ Depth prepass: '%llX'\n");
|
||||
PrintChildMat(material->depthMaterials[DEPTH_VSM], " | |-+ Depth VSM: '%llX'\n");
|
||||
PrintChildMat(material->depthMaterials[DEPTH_SHADOW_TIGHT], " | |-+ Depth shadow tight: '%llX'\n");
|
||||
PrintChildMat(material->colpassMaterial, " | |-+ Color pass: '%llX'\n");
|
||||
|
||||
Msg(eDLL_T::MS, "-+ Texture GUID map ------------------------------------------\n");
|
||||
Msg(eDLL_T::MS, " |-- Texture handles: '%llX'\n", material->textureHandles);
|
||||
|
@ -6,67 +6,88 @@
|
||||
#include "public/rendersystem/schema/texture.g.h"
|
||||
|
||||
#define MATERIAL_RENDER_PARAMS_COUNT 2 // the same for r2 and r5
|
||||
#define MATERIAL_SAMPLER_COUNT 4
|
||||
|
||||
class CMaterialGlue;
|
||||
|
||||
enum MaterialDepthPass_e
|
||||
{
|
||||
DEPTH_SHADOW,
|
||||
DEPTH_PREPASS,
|
||||
DEPTH_VSM,
|
||||
DEPTH_SHADOW_TIGHT,
|
||||
|
||||
MATERIAL_DEPTH_PASS_MAT_COUNT,
|
||||
};
|
||||
|
||||
// Virtual function-less material instance.
|
||||
struct MaterialGlue_s
|
||||
{
|
||||
PakGuid_t guid;
|
||||
const char* name;
|
||||
|
||||
const char* surfaceProp;
|
||||
const char* surfaceProp2;
|
||||
|
||||
CMaterialGlue* depthMaterials[MATERIAL_DEPTH_PASS_MAT_COUNT];
|
||||
CMaterialGlue* colpassMaterial;
|
||||
|
||||
CShaderGlue* shaderset;
|
||||
|
||||
TextureAsset_s** textureHandles;
|
||||
TextureAsset_s** streamingTextureHandles;
|
||||
uint16 streamingTextureHandleCount;
|
||||
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint16 depth;
|
||||
|
||||
// An array of indices into sampler states array. must be set properly to
|
||||
// have accurate texture tiling. Used in CShaderGlue::SetupShader (1403B3C60)
|
||||
byte samplers[MATERIAL_SAMPLER_COUNT];// example: 0x1D0300;
|
||||
|
||||
uint32 unk_7C;
|
||||
|
||||
// some features? mostly differs per material with different shader types, but
|
||||
// it seems mostly unused by the runtime too.
|
||||
uint32 unk_80_0x1F5A92BD;
|
||||
uint32 unk_84;
|
||||
|
||||
uint32 materialFlags;
|
||||
uint32 materialFlags2;
|
||||
|
||||
MaterialRenderParams_s renderParams[MATERIAL_RENDER_PARAMS_COUNT];
|
||||
uint32 numAnimationFrames;
|
||||
MaterialShaderType_e materialType;
|
||||
uint8 uberBufferFlags;
|
||||
|
||||
int dwordf4;
|
||||
void* textureAnim;
|
||||
ID3D11Buffer* uberBuffer;
|
||||
void** pID3D11BufferVTable;
|
||||
void* viewBuffer;
|
||||
|
||||
// Last frame this material was used to shift the texture streaming histogram.
|
||||
uint32 lastFrame;
|
||||
|
||||
uint16 m_iUnknown4;
|
||||
uint16 m_iUnknown5;
|
||||
uint16 m_iUnknown6;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
class CMaterialGlue : public IMaterialInternal
|
||||
{
|
||||
public:
|
||||
uint8_t pad_0008[8]; //0x0008
|
||||
uint64_t assetGuid; //0x0010
|
||||
const char* name; //0x0018
|
||||
inline const MaterialGlue_s* Get() const { return &material; }
|
||||
inline MaterialGlue_s* Get() { return &material; }
|
||||
|
||||
const char* surfaceProp; //0x0020
|
||||
const char* surfaceProp2; //0x0028
|
||||
private:
|
||||
byte reserved[8];
|
||||
MaterialGlue_s material;
|
||||
|
||||
CMaterialGlue* depthShadowMaterial; //0x0030
|
||||
CMaterialGlue* depthPrepassMaterial; //0x0038
|
||||
CMaterialGlue* depthVSMMaterial; //0x0040
|
||||
CMaterialGlue* depthShadowTightMaterial; //0x0048
|
||||
CMaterialGlue* colpassMaterial; //0x0050
|
||||
|
||||
CShaderGlue* shaderset; //0x0058
|
||||
|
||||
TextureAsset_s** textureHandles; //0x0060
|
||||
TextureAsset_s** 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
|
||||
|
||||
MaterialRenderParams_s renderParams[MATERIAL_RENDER_PARAMS_COUNT];
|
||||
|
||||
uint16_t numAnimationFrames; // used in CMaterialGlue::GetNumAnimationFrames (0x1403B4250), which is called from GetSpriteInfo @ 0x1402561FC
|
||||
uint8_t materialType;
|
||||
uint8_t bytef3;
|
||||
|
||||
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)
|
||||
#endif // !DEDICATED
|
||||
|
||||
inline void* g_pMaterialGlueVFTable = nullptr;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define TEXTURESTREAMING_H
|
||||
#include "public/rtech/istreamdb.h"
|
||||
|
||||
struct MaterialGlue_t;
|
||||
struct MaterialGlue_s;
|
||||
struct TextureAsset_s;
|
||||
|
||||
struct TextureStreamMgr_Task_s
|
||||
@ -78,7 +78,7 @@ struct TextureStreamMgr_s
|
||||
char* stringBuffer;
|
||||
StreamDB_Header_s header;
|
||||
StreamDB_ResidentPage_s* residentPages;
|
||||
MaterialGlue_t** materials;
|
||||
MaterialGlue_s** materials;
|
||||
StreamDB_Material_s* materialInfo;
|
||||
int64 maxResidentPageSize;
|
||||
StreamDB_PageState_s pageStates[4];
|
||||
|
@ -297,18 +297,21 @@ void CTextOverlay::DrawGPUStats(void) const
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTextOverlay::DrawCrosshairMaterial(void) const
|
||||
{
|
||||
CMaterialGlue* pMaterialGlue = v_GetMaterialAtCrossHair();
|
||||
if (!pMaterialGlue)
|
||||
const CMaterialGlue* const materialGlue = v_GetMaterialAtCrossHair();
|
||||
|
||||
if (!materialGlue)
|
||||
return;
|
||||
|
||||
const MaterialGlue_s* const material = materialGlue->Get();
|
||||
static const 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->name,
|
||||
pMaterialGlue->assetGuid,
|
||||
pMaterialGlue->width, pMaterialGlue->height,
|
||||
pMaterialGlue->surfaceProp, pMaterialGlue->surfaceProp2,
|
||||
pMaterialGlue->numStreamingTextureHandles,
|
||||
pMaterialGlue->shaderset->m_nTextureInputCount);
|
||||
|
||||
DrawFormat(cl_materialinfo_offset_x.GetInt(), cl_materialinfo_offset_y.GetInt(), c, "name: %s\nguid: %llx\ndimensions: %hu x %hu\nsurface: %s/%s\nstc: %hu\ntc: %hu",
|
||||
material->name,
|
||||
material->guid,
|
||||
material->width, material->height,
|
||||
material->surfaceProp, material->surfaceProp2,
|
||||
material->streamingTextureHandleCount,
|
||||
material->shaderset->m_nTextureInputCount);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user