This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,216 @@
//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
//===========================================================================//
#include "shaderlib/ShaderDLL.h"
#include "materialsystem/IShader.h"
#include "tier1/utlvector.h"
#include "tier1/utllinkedlist.h"
#include "tier0/dbg.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "materialsystem/materialsystem_config.h"
#include "materialsystem/ishadersystem.h"
#include "materialsystem/ishaderapi.h"
#include "shaderlib_cvar.h"
#include "mathlib/mathlib.h"
#include "tier2/tier2.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// The standard implementation of CShaderDLL
//-----------------------------------------------------------------------------
class CShaderDLL : public IShaderDLLInternal, public IShaderDLL
{
public:
CShaderDLL();
// methods of IShaderDLL
virtual bool Connect( CreateInterfaceFn factory );
virtual void Disconnect();
// methods of IShaderDLLInternal
virtual int ShaderCount() const;
virtual IShader *GetShader( int nShader );
int ShaderComboSemanticsCount() const;
const ShaderComboSemantics_t *GetComboSemantics( int n );
virtual bool Connect( CreateInterfaceFn factory, bool bIsMaterialSystem );
virtual void Disconnect( bool bIsMaterialSystem );
virtual void InsertShader( IShader *pShader );
virtual void AddShaderComboInformation( const ShaderComboSemantics_t *pSemantics );
private:
CUtlVector< IShader * > m_ShaderList;
CUtlLinkedList< const ShaderComboSemantics_t * > m_ShaderComboSemantics;
};
//-----------------------------------------------------------------------------
// Global interfaces/structures
//-----------------------------------------------------------------------------
#if !defined( _PS3 ) && !defined( _OSX )
IMaterialSystemHardwareConfig* g_pHardwareConfig;
const MaterialSystem_Config_t *g_pConfig;
#else
extern MaterialSystem_Config_t g_config;
const MaterialSystem_Config_t *g_pConfig = &g_config;
#endif
//-----------------------------------------------------------------------------
// Interfaces/structures local to shaderlib
//-----------------------------------------------------------------------------
#ifndef _PS3
IShaderSystem* g_pSLShaderSystem;
#endif
// Pattern necessary because shaders register themselves in global constructors
static CShaderDLL *s_pShaderDLL;
//-----------------------------------------------------------------------------
// Global accessor
//-----------------------------------------------------------------------------
IShaderDLL *GetShaderDLL()
{
// Pattern necessary because shaders register themselves in global constructors
if ( !s_pShaderDLL )
{
s_pShaderDLL = new CShaderDLL;
}
return s_pShaderDLL;
}
IShaderDLLInternal *GetShaderDLLInternal()
{
// Pattern necessary because shaders register themselves in global constructors
if ( !s_pShaderDLL )
{
s_pShaderDLL = new CShaderDLL;
}
return static_cast<IShaderDLLInternal*>( s_pShaderDLL );
}
//-----------------------------------------------------------------------------
// Singleton interface
//-----------------------------------------------------------------------------
EXPOSE_INTERFACE_FN( (InstantiateInterfaceFn)GetShaderDLLInternal, IShaderDLLInternal, SHADER_DLL_INTERFACE_VERSION );
//-----------------------------------------------------------------------------
// Connect, disconnect...
//-----------------------------------------------------------------------------
CShaderDLL::CShaderDLL()
{
MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
}
//-----------------------------------------------------------------------------
// Connect, disconnect...
//-----------------------------------------------------------------------------
bool CShaderDLL::Connect( CreateInterfaceFn factory, bool bIsMaterialSystem )
{
#if defined( _PS3 )
return true;
#elif defined( OSX )
g_pSLShaderSystem = (IShaderSystem*)factory( SHADERSYSTEM_INTERFACE_VERSION, NULL );
return ( g_pSLShaderSystem != NULL );
#else
g_pHardwareConfig = (IMaterialSystemHardwareConfig*)factory( MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, NULL );
g_pConfig = (const MaterialSystem_Config_t*)factory( MATERIALSYSTEM_CONFIG_VERSION, NULL );
g_pSLShaderSystem = (IShaderSystem*)factory( SHADERSYSTEM_INTERFACE_VERSION, NULL );
if ( !bIsMaterialSystem )
{
ConnectTier1Libraries( &factory, 1 );
InitShaderLibCVars( factory );
}
return ( g_pConfig != NULL ) && (g_pHardwareConfig != NULL) && ( g_pSLShaderSystem != NULL );
#endif
}
void CShaderDLL::Disconnect( bool bIsMaterialSystem )
{
#if defined( OSX )
g_pSLShaderSystem = NULL;
#elif !defined( _PS3 )
if ( !bIsMaterialSystem )
{
ConVar_Unregister();
DisconnectTier1Libraries();
}
g_pHardwareConfig = NULL;
g_pConfig = NULL;
g_pSLShaderSystem = NULL;
#endif
}
bool CShaderDLL::Connect( CreateInterfaceFn factory )
{
return Connect( factory, false );
}
void CShaderDLL::Disconnect()
{
Disconnect( false );
}
//-----------------------------------------------------------------------------
// Iterates over all shaders
//-----------------------------------------------------------------------------
int CShaderDLL::ShaderCount() const
{
return m_ShaderList.Count();
}
IShader *CShaderDLL::GetShader( int nShader )
{
if ( ( nShader < 0 ) || ( nShader >= m_ShaderList.Count() ) )
return NULL;
return m_ShaderList[nShader];
}
//-----------------------------------------------------------------------------
// Adds to the shader lists
//-----------------------------------------------------------------------------
void CShaderDLL::InsertShader( IShader *pShader )
{
Assert( pShader );
m_ShaderList.AddToTail( pShader );
}
//-----------------------------------------------------------------------------
// Iterates over all shader semantics
//-----------------------------------------------------------------------------
int CShaderDLL::ShaderComboSemanticsCount() const
{
return m_ShaderComboSemantics.Count();
}
const ShaderComboSemantics_t *CShaderDLL::GetComboSemantics( int n )
{
if ( ( n < 0 ) || ( n >= m_ShaderComboSemantics.Count() ) )
return NULL;
return m_ShaderComboSemantics[n];
}
//-----------------------------------------------------------------------------
// Adds to the shader combo semantics list
//-----------------------------------------------------------------------------
void CShaderDLL::AddShaderComboInformation( const ShaderComboSemantics_t *pSemantics )
{
m_ShaderComboSemantics.AddToTail( pSemantics );
}

View File

@@ -0,0 +1,28 @@
// ----------------------------------------- //
// File generated by VPC //
// ----------------------------------------- //
Source file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\BaseShader.cpp
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\BaseShader.cpp
Release output file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\BaseShader.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\ShaderDLL.cpp
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\ShaderDLL.cpp
Release output file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\ShaderDLL.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\shaderlib_cvar.cpp
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\shaderlib_cvar.cpp
Release output file: F:\csgo_64\cstrike15_src\materialsystem\shaderlib\shaderlib_cvar.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\common\debug_lib_check.cpp
Debug output file: F:\csgo_64\cstrike15_src\common\debug_lib_check.cpp
Release output file: F:\csgo_64\cstrike15_src\common\debug_lib_check.cpp
Containing unity file:
PCH file:

View File

@@ -0,0 +1,44 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Header: $
// $NoKeywords: $
//=============================================================================//
#ifndef SHADERDLL_GLOBAL_H
#define SHADERDLL_GLOBAL_H
#ifdef _WIN32
#pragma once
#endif
#ifdef _PS3
class CPs3NonVirt_IShaderSystem;
inline CPs3NonVirt_IShaderSystem *GetShaderSystem()
{
return NULL;
}
#else
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
class IShaderSystem;
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
inline IShaderSystem *GetShaderSystem()
{
extern IShaderSystem* g_pSLShaderSystem;
return g_pSLShaderSystem;
}
#endif
#endif // SHADERDLL_GLOBAL_H

View File

@@ -0,0 +1,51 @@
//-----------------------------------------------------------------------------
// SHADERLIB.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$macro SRCDIR "..\.."
$Macro SHADERLIBDIR "."
$include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
$Configuration
{
$Compiler
{
$AdditionalIncludeDirectories "$BASE;..\"
$PreprocessorDefinitions "$BASE;FAST_MATERIALVAR_ACCESS"
}
}
$include "shaderlib_inc.vpc"
$Project "shaderlib"
{
$Folder "External Header Files"
{
$File "$SRCDIR\public\tier0\basetypes.h"
$File "$SRCDIR\public\tier0\dbg.h"
$File "$SRCDIR\public\tier0\fasttimer.h"
$File "$SRCDIR\public\appframework\iappsystem.h"
$File "$SRCDIR\public\tier0\icommandline.h"
$File "$SRCDIR\public\icvar.h"
$File "$SRCDIR\public\materialsystem\imaterial.h"
$File "$SRCDIR\public\materialsystem\imaterialsystem.h"
$File "$SRCDIR\public\materialsystem\imaterialsystemhardwareconfig.h"
$File "$SRCDIR\public\materialsystem\imaterialvar.h"
$File "$SRCDIR\public\materialsystem\imesh.h"
$File "$SRCDIR\public\materialsystem\IShader.h"
$File "$SRCDIR\public\materialsystem\ishaderapi.h"
$File "$SRCDIR\public\materialsystem\itexture.h"
$File "$SRCDIR\public\materialsystem\materialsystem_config.h"
$File "$SRCDIR\public\tier0\memdbgoff.h"
$File "$SRCDIR\public\tier0\memdbgon.h"
$File "$SRCDIR\public\tier0\platform.h"
$File "$SRCDIR\public\string_t.h"
$File "$SRCDIR\public\tier1\strtools.h"
$File "$SRCDIR\public\tier1\utlmemory.h"
$File "$SRCDIR\public\tier1\utlvector.h"
$File "$SRCDIR\public\vstdlib\vstdlib.h"
}
}

View File

@@ -0,0 +1,13 @@
"vpc_cache"
{
"CacheVersion" "1"
"win32"
{
"CRCFile" "shaderlib.vcxproj.vpc_crc"
"OutputFiles"
{
"0" "shaderlib.vcxproj"
"1" "shaderlib.vcxproj.filters"
}
}
}

View File

@@ -0,0 +1,42 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
//===========================================================================//
#include "icvar.h"
#include "tier1/tier1.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
// ------------------------------------------------------------------------------------------- //
// ConVar stuff.
// ------------------------------------------------------------------------------------------- //
class CShaderLibConVarAccessor : public IConCommandBaseAccessor
{
public:
virtual bool RegisterConCommandBase( ConCommandBase *pCommand )
{
// Link to engine's list instead
g_pCVar->RegisterConCommand( pCommand );
char const *pValue = g_pCVar->GetCommandLineValue( pCommand->GetName() );
if( pValue && !pCommand->IsCommand() )
{
( ( ConVar * )pCommand )->SetValue( pValue );
}
return true;
}
};
CShaderLibConVarAccessor g_ConVarAccessor;
void InitShaderLibCVars( CreateInterfaceFn cvarFactory )
{
if ( g_pCVar )
{
ConVar_Register( FCVAR_MATERIAL_SYSTEM_THREAD, &g_ConVarAccessor );
}
}

View File

@@ -0,0 +1,20 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef SHADERLIB_CVAR_H
#define SHADERLIB_CVAR_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
void InitShaderLibCVars( CreateInterfaceFn cvarFactory );
#endif // SHADERLIB_CVAR_H

View File

@@ -0,0 +1,25 @@
$Project
{
$Folder "ShaderLib"
{
$Folder "Source Files"
{
$File "$SHADERLIBDIR\BaseShader.cpp"
$File "$SHADERLIBDIR\ShaderDLL.cpp"
$File "$SHADERLIBDIR\shaderlib_cvar.cpp"
}
$Folder "Header Files"
{
$File "$SHADERLIBDIR\shaderDLL_Global.h"
$File "$SHADERLIBDIR\shaderlib_cvar.h"
$File "$SRCDIR\public\shaderlib\BaseShader.h"
$File "$SRCDIR\public\shaderlib\cshader.h"
$File "$SRCDIR\public\shaderlib\ShaderDLL.h"
$File "$SRCDIR\public\shaderlib\commandbuilder.h"
}
}
}