r5sdk/r5dev/materialsystem/cshaderglue.h
Kawe Mazidjatari edc52ad669 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-04-05 17:19:32 +02:00

58 lines
2.5 KiB
C++

#pragma once
#pragma pack(push, 1)
class CShaderGlue // Most of these found in CShaderGlue::SetupShader
{
public:
int SetupShader(uint64_t nCount, uint64_t a3, void* pRawMaterialGlueWithoutVTable);
void* m_pVTable; //0x0000
char pad_0008[8]; //0x0008 Dispatcher Context, Some SEH try and catch thing.
uint64_t m_nUnknown1; //0x0010
uint16_t m_nCount1; //0x0018
uint16_t m_nTextureInputCount; //0x001A
uint16_t m_nNumSamplers; //0x001C [ PIXIE ]: Used by ID3D11DeviceContext::PSSetSamplers to set NumSamplers
uint8_t m_nStartSlot; //0x001E [ PIXIE ]: Used by ID3D11DeviceContext::PSSetShaderResources to set StartSlot.
uint8_t m_nNumViews; //0x001F [ PIXIE ]: Used by ID3D11DeviceContext::PSSetShaderResources to set NumViews.
uint8_t m_nByte1; //0x0020 [ PIXIE ]: No clue tbh the only usage is an example I will show below. All of the usages are cmp also..?
uint8_t pad_0021[15]; //0x0021
void** m_ppVertexShader; //0x0030 [ PIXIE ]: Points to another structure which holds a double ptr to d3d11.dll
void** m_ppPixelShader; //0x0038 [ PIXIE ]: Points to another structure which holds a double ptr to d3d11.dll
}; //Size: 0x0040
static_assert(sizeof(CShaderGlue) == 0x40); // [ PIXIE ]: All vars have proper datatype size, paddings are unknown.
#pragma pack(pop)
/*
if ( *(_BYTE *)(v19 + a1 + 32) != byte_14171A08A ) // (v19 + a1 + 32) = m_nByte1
{
byte_14171A08A = *(_BYTE *)(v19 + a1 + 32);
qword_14171AE78 = -1i64;
}
*/
/* ==== CSHADERGLUE ================================================================================================================================================== */
inline int(*CShaderGlue_SetupShader)(CShaderGlue* thisptr, uint64_t nCount, uint64_t a3, void* pRawMaterialGlueWithoutVTable);
inline void* g_pShaderGlueVFTable = nullptr;
///////////////////////////////////////////////////////////////////////////////
class VShaderGlue : public IDetour
{
virtual void GetAdr(void) const
{
LogConAdr("CShaderGlue::`vftable'", g_pShaderGlueVFTable);
LogFunAdr("CShaderGlue::SetupShader", CShaderGlue_SetupShader);
}
virtual void GetFun(void) const
{
CShaderGlue_SetupShader = CMemory(g_pShaderGlueVFTable).WalkVTable(4).Deref().RCast<int(*)(CShaderGlue*, uint64_t, uint64_t, void*)>();
}
virtual void GetVar(void) const { }
virtual void GetCon(void) const
{
g_pShaderGlueVFTable = g_GameDll.GetVirtualMethodTable(".?AVCShaderGlue@@");
}
virtual void Detour(const bool bAttach) const { }
};
///////////////////////////////////////////////////////////////////////////////