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.

51 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: .360 file creation of shaders
  4. //
  5. //=====================================================================================//
  6. #include "MakeGameData.h"
  7. #include "materialsystem/shader_vcs_version.h"
  8. #define SHADER_FILE_THRESHOLD 32*1024
  9. //-----------------------------------------------------------------------------
  10. // Get the preload data for a vcs file
  11. //-----------------------------------------------------------------------------
  12. bool GetPreloadData_VCS( const char *pFilename, CUtlBuffer &fileBufferIn, CUtlBuffer &preloadBufferOut )
  13. {
  14. ShaderHeader_t *pHeader = (ShaderHeader_t *)fileBufferIn.Base();
  15. unsigned int version = BigLong( pHeader->m_nVersion );
  16. // ensure caller's buffer is clean
  17. // caller determines preload size, via TellMaxPut()
  18. preloadBufferOut.Purge();
  19. unsigned int nPreloadSize;
  20. if ( fileBufferIn.TellMaxPut() <= SHADER_FILE_THRESHOLD )
  21. {
  22. // include the whole file
  23. nPreloadSize = fileBufferIn.TellMaxPut();
  24. }
  25. else
  26. {
  27. if ( version < SHADER_VCS_VERSION_NUMBER )
  28. {
  29. // not supporting old versions
  30. return false;
  31. }
  32. if ( version != SHADER_VCS_VERSION_NUMBER )
  33. {
  34. // bad version
  35. Msg( "Can't preload: '%s', expecting version %d got version %d\n", pFilename, SHADER_VCS_VERSION_NUMBER, version );
  36. return false;
  37. }
  38. nPreloadSize = sizeof( ShaderHeader_t ) + BigLong( pHeader->m_nNumStaticCombos ) * sizeof( StaticComboRecord_t );
  39. }
  40. preloadBufferOut.Put( fileBufferIn.Base(), nPreloadSize );
  41. return true;
  42. }