From 0b5a04e732b4d10dafeccf0e3f5f583c025c0f06 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Mon, 30 Nov 2020 21:44:53 +0300 Subject: [PATCH] add stubs for asan/ubsan --- engine/ModelInfo.cpp | 4 +- materialsystem/mat_stub.cpp | 91 +------------ materialsystem/mat_stub.h | 93 +++++++++++++ materialsystem/shadersystem.cpp | 7 +- togl/linuxwin/asanstubs.cpp | 17 +++ togl/togl.vpc | 3 +- vguimatsurface/asanstubs.cpp | 217 ++++++++++++++++++++++++++++++ vguimatsurface/vguimatsurface.vpc | 1 + 8 files changed, 338 insertions(+), 95 deletions(-) create mode 100644 materialsystem/mat_stub.h create mode 100644 togl/linuxwin/asanstubs.cpp create mode 100644 vguimatsurface/asanstubs.cpp diff --git a/engine/ModelInfo.cpp b/engine/ModelInfo.cpp index e5ea9a0b..d5d1f371 100644 --- a/engine/ModelInfo.cpp +++ b/engine/ModelInfo.cpp @@ -95,8 +95,8 @@ static int ModelFrameCount( model_t *model ) class CNetworkStringTable_LockOverride : public CNetworkStringTable { private: - CNetworkStringTable_LockOverride(); // no impl - ~CNetworkStringTable_LockOverride(); // no impl +// CNetworkStringTable_LockOverride(); // no impl +// ~CNetworkStringTable_LockOverride(); // no impl CNetworkStringTable_LockOverride(const CNetworkStringTable_LockOverride &); // no impl CNetworkStringTable_LockOverride& operator=(const CNetworkStringTable_LockOverride &); // no impl public: diff --git a/materialsystem/mat_stub.cpp b/materialsystem/mat_stub.cpp index 67d77f87..c9820c2c 100644 --- a/materialsystem/mat_stub.cpp +++ b/materialsystem/mat_stub.cpp @@ -20,6 +20,9 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#include "mat_stub.h" + +CDummyTexture g_DummyTexture; // ---------------------------------------------------------------------------------------- // // IMaterialSystem and IMesh stub classes. @@ -223,94 +226,6 @@ CDummyMesh* GetDummyMesh() return g_pDummyMesh; } - -// ---------------------------------------------------------------------------------------- // -// ITexture dummy implementation. -// ---------------------------------------------------------------------------------------- // - -class CDummyTexture : public ITexture -{ -public: - // Various texture polling methods - virtual const char *GetName( void ) const { return "DummyTexture"; } - virtual int GetMappingWidth() const { return 512; } - virtual int GetMappingHeight() const { return 512; } - virtual int GetActualWidth() const { return 512; } - virtual int GetActualHeight() const { return 512; } - virtual int GetNumAnimationFrames() const { return 0; } - virtual bool IsTranslucent() const { return false; } - virtual bool IsMipmapped() const { return false; } - - virtual void GetLowResColorSample( float s, float t, float *color ) const {} - - // Gets texture resource data of the specified type. - // Params: - // eDataType type of resource to retrieve. - // pnumBytes on return is the number of bytes available in the read-only data buffer or is undefined - // Returns: - // pointer to the resource data, or NULL - virtual void *GetResourceData( uint32 eDataType, size_t *pNumBytes ) const - { - return NULL; - } - - - // Methods associated with reference count - virtual void IncrementReferenceCount( void ) {} - virtual void DecrementReferenceCount( void ) {} - - // Used to modify the texture bits (procedural textures only) - virtual void SetTextureRegenerator( ITextureRegenerator *pTextureRegen ) {} - - // Reconstruct the texture bits in HW memory - - // If rect is not specified, reconstruct all bits, otherwise just - // reconstruct a subrect. - virtual void Download( Rect_t *pRect = 0, int nAdditionalCreationFlags = 0 ) {} - - // Uses for stats. . .get the approximate size of the texture in it's current format. - virtual int GetApproximateVidMemBytes( void ) const { return 64; } - - virtual bool IsError() const { return false; } - - virtual ITexture *GetEmbeddedTexture( int nIndex ) { return NULL; } - - // For volume textures - virtual bool IsVolumeTexture() const { return false; } - virtual int GetMappingDepth() const { return 1; } - virtual int GetActualDepth() const { return 1; } - - virtual ImageFormat GetImageFormat() const { return IMAGE_FORMAT_RGBA8888; } - virtual NormalDecodeMode_t GetNormalDecodeMode() const { return NORMAL_DECODE_NONE; } - - // Various information about the texture - virtual bool IsRenderTarget() const { return false; } - virtual bool IsCubeMap() const { return false; } - virtual bool IsNormalMap() const { return false; } - virtual bool IsProcedural() const { return false; } - virtual void DeleteIfUnreferenced() {} - - virtual void SwapContents( ITexture *pOther ) {} - - virtual unsigned int GetFlags( void ) const { return 0; } - virtual void ForceLODOverride( int iNumLodsOverrideUpOrDown ) { NULL; } - -#if defined( _X360 ) - virtual bool ClearTexture( int r, int g, int b, int a ) { return true; } - virtual bool CreateRenderTargetSurface( int width, int height, ImageFormat format, bool bSameAsTexture ) { return true; } -#endif - - // Save texture to a file. - virtual bool SaveToFile( const char *fileName ) { return false; } - - void CopyToStagingTexture( ITexture* pDstTex ) {} - - virtual void SetErrorTexture( bool bIsErrorTexture ) { } -}; - -CDummyTexture g_DummyTexture; - - // ---------------------------------------------------------------------------------------- // // Dummy implementation of IMaterialVar. // ---------------------------------------------------------------------------------------- // diff --git a/materialsystem/mat_stub.h b/materialsystem/mat_stub.h new file mode 100644 index 00000000..051079fe --- /dev/null +++ b/materialsystem/mat_stub.h @@ -0,0 +1,93 @@ +#ifndef MAT_STUB_H +#define MAT_STUB_H +#include "materialsystem/itexture.h" + +// ---------------------------------------------------------------------------------------- // +// ITexture dummy implementation. +// ---------------------------------------------------------------------------------------- // + +class CDummyTexture : public ITexture +{ +public: + // Various texture polling methods + virtual const char *GetName( void ) const { return "DummyTexture"; } + virtual int GetMappingWidth() const { return 512; } + virtual int GetMappingHeight() const { return 512; } + virtual int GetActualWidth() const { return 512; } + virtual int GetActualHeight() const { return 512; } + virtual int GetNumAnimationFrames() const { return 0; } + virtual bool IsTranslucent() const { return false; } + virtual bool IsMipmapped() const { return false; } + + virtual void GetLowResColorSample( float s, float t, float *color ) const {} + + // Gets texture resource data of the specified type. + // Params: + // eDataType type of resource to retrieve. + // pnumBytes on return is the number of bytes available in the read-only data buffer or is undefined + // Returns: + // pointer to the resource data, or NULL + virtual void *GetResourceData( uint32 eDataType, size_t *pNumBytes ) const + { + return NULL; + } + + + // Methods associated with reference count + virtual void IncrementReferenceCount( void ) {} + virtual void DecrementReferenceCount( void ) {} + + // Used to modify the texture bits (procedural textures only) + virtual void SetTextureRegenerator( ITextureRegenerator *pTextureRegen ) {} + + // Reconstruct the texture bits in HW memory + + // If rect is not specified, reconstruct all bits, otherwise just + // reconstruct a subrect. + virtual void Download( Rect_t *pRect = 0, int nAdditionalCreationFlags = 0 ) {} + + // Uses for stats. . .get the approximate size of the texture in it's current format. + virtual int GetApproximateVidMemBytes( void ) const { return 64; } + + virtual bool IsError() const { return false; } + + virtual ITexture *GetEmbeddedTexture( int nIndex ) { return NULL; } + + // For volume textures + virtual bool IsVolumeTexture() const { return false; } + virtual int GetMappingDepth() const { return 1; } + virtual int GetActualDepth() const { return 1; } + + virtual ImageFormat GetImageFormat() const { return IMAGE_FORMAT_RGBA8888; } + virtual NormalDecodeMode_t GetNormalDecodeMode() const { return NORMAL_DECODE_NONE; } + + // Various information about the texture + virtual bool IsRenderTarget() const { return false; } + virtual bool IsCubeMap() const { return false; } + virtual bool IsNormalMap() const { return false; } + virtual bool IsProcedural() const { return false; } + virtual void DeleteIfUnreferenced() {} + + virtual void SwapContents( ITexture *pOther ) {} + + virtual unsigned int GetFlags( void ) const { return 0; } + virtual void ForceLODOverride( int iNumLodsOverrideUpOrDown ) { NULL; } + +#if defined( _X360 ) + virtual bool ClearTexture( int r, int g, int b, int a ) { return true; } + virtual bool CreateRenderTargetSurface( int width, int height, ImageFormat format, bool bSameAsTexture ) { return true; } +#endif + + // Save texture to a file. + virtual bool SaveToFile( const char *fileName ) { return false; } + + void CopyToStagingTexture( ITexture* pDstTex ) {} + + virtual void SetErrorTexture( bool bIsErrorTexture ) { } +}; + +extern CDummyTexture g_DummyTexture; + + + +#endif // MAT_STUB_H diff --git a/materialsystem/shadersystem.cpp b/materialsystem/shadersystem.cpp index 7d530605..3524453b 100644 --- a/materialsystem/shadersystem.cpp +++ b/materialsystem/shadersystem.cpp @@ -27,6 +27,7 @@ // NOTE: This must be the last file included! #include "tier0/memdbgon.h" +#include "mat_stub.h" //#define DEBUG_DEPTH 1 @@ -38,7 +39,6 @@ static ConVar mat_showenvmapmask( "mat_showenvmapmask", "0" ); static ConVar mat_debugdepth( "mat_debugdepth", "0" ); extern ConVar mat_supportflashlight; - //----------------------------------------------------------------------------- // Implementation of the shader system //----------------------------------------------------------------------------- @@ -2024,10 +2024,9 @@ void CShaderSystem::LoadCubeMap( IMaterialVar **ppParams, IMaterialVar *pTexture if ( stricmp( pTextureVar->GetStringValue(), "env_cubemap" ) == 0 ) { - // garymcthack - // don't have to load anything here. . just set the texture value to something + // don't have to load anything here. . just set the texture value to DummyTexture // special that says to use the cubemap entity. - pTextureVar->SetTextureValue( ( ITexture * )-1 ); + pTextureVar->SetTextureValue( &g_DummyTexture ); SetFlags2( ppParams, MATERIAL_VAR2_USES_ENV_CUBEMAP ); } else diff --git a/togl/linuxwin/asanstubs.cpp b/togl/linuxwin/asanstubs.cpp new file mode 100644 index 00000000..ee4ce50b --- /dev/null +++ b/togl/linuxwin/asanstubs.cpp @@ -0,0 +1,17 @@ +typedef unsigned int uint; + +#include "../public/togl/linuxwin/glmdisplay.h" +#include "../public/togl/linuxwin/glmdisplaydb.h" + +void GLMDisplayDB::PopulateRenderers( void ) { } +void GLMDisplayDB::PopulateFakeAdapters( uint realRendererIndex ) { } // fake adapters = one real adapter times however many displays are on +void GLMDisplayDB::Populate( void ) { } +int GLMDisplayDB::GetFakeAdapterCount( void ) { return 1; } +bool GLMDisplayDB::GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut ) { return true; } +int GLMDisplayDB::GetRendererCount( void ) { return 1; } +bool GLMDisplayDB::GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut ) { return true; } +int GLMDisplayDB::GetDisplayCount( int rendererIndex ) { return 1; } +bool GLMDisplayDB::GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut ) { return true; } +int GLMDisplayDB::GetModeCount( int rendererIndex, int displayIndex ) { } +bool GLMDisplayDB::GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut ) { return false; } +void GLMDisplayDB::Dump( void ) { } diff --git a/togl/togl.vpc b/togl/togl.vpc index fe423b46..dadbcd72 100644 --- a/togl/togl.vpc +++ b/togl/togl.vpc @@ -70,7 +70,8 @@ $Project "togl" $File "$TOGL_SRCDIR/cglmfbo.cpp" $File "$TOGL_SRCDIR/cglmprogram.cpp" $File "$TOGL_SRCDIR/cglmbuffer.cpp" - $File "$TOGL_SRCDIR/cglmquery.cpp" + $File "$TOGL_SRCDIR/cglmquery.cpp" + $File "$TOGL_SRCDIR/asanstubs.cpp" } $Folder "DirectX Header Files" [$WIN32 && !$GL] diff --git a/vguimatsurface/asanstubs.cpp b/vguimatsurface/asanstubs.cpp new file mode 100644 index 00000000..37052507 --- /dev/null +++ b/vguimatsurface/asanstubs.cpp @@ -0,0 +1,217 @@ +#include + +#include +#include +#include +#include +#include + +#include "../vgui2/src/vgui_internal.h" +#include "../vgui2/src/VPanel.h" + +#include "tier0/minidump.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +using namespace vgui; + +VPanel::VPanel() +{ +} + +VPanel::~VPanel() +{ +} + +void VPanel::TraverseLevel( int val ) +{ +} + +void VPanel::Init(IClientPanel *attachedClientPanel) +{ +} + +void VPanel::Solve() +{ +} + +void VPanel::SetPos(int x, int y) +{ +} + +void VPanel::GetPos(int &x, int &y) +{ +} + +void VPanel::SetSize(int wide,int tall) +{ +} + +void VPanel::GetSize(int& wide,int& tall) +{ +} + +void VPanel::SetMinimumSize(int wide,int tall) +{ +} + +void VPanel::GetMinimumSize(int &wide, int &tall) +{ +} + +void VPanel::SetVisible(bool state) +{ +} + +void VPanel::SetEnabled(bool state) +{ +} + +bool VPanel::IsVisible() +{ +} + +bool VPanel::IsEnabled() +{ +} + +void VPanel::GetAbsPos(int &x, int &y) +{ +} + +void VPanel::GetInternalAbsPos(int &x, int &y) +{ +} + +void VPanel::GetClipRect(int &x0, int &y0, int &x1, int &y1) +{ +} + +void VPanel::SetInset(int left, int top, int right, int bottom) +{ +} + +void VPanel::GetInset(int &left, int &top, int &right, int &bottom) +{ +} + +void VPanel::SetParent(VPanel *newParent) +{ +} + +int VPanel::GetChildCount() +{ + return 0; +} + +VPanel *VPanel::GetChild(int index) +{ + return NULL; +} + +CUtlVector< VPanel *> &VPanel::GetChildren() +{ +// return NULL; +} + +VPanel *VPanel::GetParent() +{ + return NULL; +} + +void VPanel::SetZPos(int z) +{ +} + +int VPanel::GetZPos() +{ + return 0; +} + +void VPanel::MoveToFront(void) +{ +} + +void VPanel::MoveToBack() +{ +} + +bool VPanel::HasParent(VPanel *potentialParent) +{ + return true; +} + +SurfacePlat *VPanel::Plat() +{ + return NULL; +} + +void VPanel::SetPlat(SurfacePlat *Plat) +{ +} + +bool VPanel::IsPopup() +{ +} + +void VPanel::SetPopup(bool state) +{ +} + +bool VPanel::IsTopmostPopup() const +{ + return true; +} + +void VPanel::SetTopmostPopup( bool bEnable ) +{ +} + +bool VPanel::IsFullyVisible() +{ + return true; +} + +const char *VPanel::GetName() +{ + return ""; +} + +const char *VPanel::GetClassName() +{ + return ""; +} + +HScheme VPanel::GetScheme() +{ + return NULL; +} + + +void VPanel::SendMessage(KeyValues *params, VPANEL ifrompanel) +{ +} + + +void VPanel::SetKeyBoardInputEnabled(bool state) +{ +} + +void VPanel::SetMouseInputEnabled(bool state) +{ +} + +bool VPanel::IsKeyBoardInputEnabled() +{ + return true; +} + +bool VPanel::IsMouseInputEnabled() +{ + return true; +} + +void VPanel::SetSiblingPin(VPanel *newSibling, byte iMyCornerToPin, byte iSiblingCornerToPinTo ) +{ +} diff --git a/vguimatsurface/vguimatsurface.vpc b/vguimatsurface/vguimatsurface.vpc index 391ca91a..9e059488 100644 --- a/vguimatsurface/vguimatsurface.vpc +++ b/vguimatsurface/vguimatsurface.vpc @@ -41,6 +41,7 @@ $Project "vguimatsurface" $File "FontTextureCache.cpp" $File "Input.cpp" $File "MatSystemSurface.cpp" + $File "asanstubs.cpp" $File "memorybitmap.cpp" [$WIN32] $File "TextureDictionary.cpp" $File "$SRCDIR\vgui2\src\vgui_key_translation.cpp"