Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.5 KiB

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: .360 file creation of shaders
//
//=====================================================================================//
#include "MakeGameData.h"
#include "materialsystem/shader_vcs_version.h"
#define SHADER_FILE_THRESHOLD 32*1024
//-----------------------------------------------------------------------------
// Get the preload data for a vcs file
//-----------------------------------------------------------------------------
bool GetPreloadData_VCS( const char *pFilename, CUtlBuffer &fileBufferIn, CUtlBuffer &preloadBufferOut )
{
ShaderHeader_t *pHeader = (ShaderHeader_t *)fileBufferIn.Base();
unsigned int version = BigLong( pHeader->m_nVersion );
// ensure caller's buffer is clean
// caller determines preload size, via TellMaxPut()
preloadBufferOut.Purge();
unsigned int nPreloadSize;
if ( fileBufferIn.TellMaxPut() <= SHADER_FILE_THRESHOLD )
{
// include the whole file
nPreloadSize = fileBufferIn.TellMaxPut();
}
else
{
if ( version < SHADER_VCS_VERSION_NUMBER )
{
// not supporting old versions
return false;
}
if ( version != SHADER_VCS_VERSION_NUMBER )
{
// bad version
Msg( "Can't preload: '%s', expecting version %d got version %d\n", pFilename, SHADER_VCS_VERSION_NUMBER, version );
return false;
}
nPreloadSize = sizeof( ShaderHeader_t ) + BigLong( pHeader->m_nNumStaticCombos ) * sizeof( StaticComboRecord_t );
}
preloadBufferOut.Put( fileBufferIn.Base(), nPreloadSize );
return true;
}