Counter Strike : Global Offensive Source Code
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.

321 lines
11 KiB

  1. @echo off
  2. set TTEXE=..\..\devtools\bin\timeprecise.exe
  3. if not exist %TTEXE% goto no_ttexe
  4. goto no_ttexe_end
  5. :no_ttexe
  6. set TTEXE=time /t
  7. :no_ttexe_end
  8. echo.
  9. rem echo ==================== buildshaders %* ==================
  10. %TTEXE% -cur-Q
  11. set tt_start=%ERRORLEVEL%
  12. set tt_chkpt=%tt_start%
  13. REM ****************
  14. REM usage: buildshaders <shaderProjectName> [-x360|-ps3]
  15. REM ****************
  16. setlocal
  17. set arg_filename=%1
  18. rem set shadercompilecommand=echo shadercompile.exe -mpi_graphics -mpi_TrackEvents
  19. set shadercompilecommand=shadercompile.exe
  20. set shadercompileworkers=140
  21. set x360_args=
  22. set ps3_args=
  23. set ps3_additional_args=
  24. set targetdir=..\..\..\game\platform\shaders
  25. set SrcDirBase=..\..
  26. set ChangeToDir=../../../game/bin
  27. set shaderDir=shaders
  28. set SDKArgs=
  29. set SHADERINCPATH=vshtmp9/... fxctmp9/...
  30. set DIRECTX_SDK_VER=pc09.00
  31. set DIRECTX_SDK_BIN_DIR=dx9sdk\utilities
  32. if /i "%2" == "-x360" goto dx_sdk_x360
  33. if /i "%2" == "-ps3" goto dx_sdk_ps3
  34. if /i "%2" == "-dx9_30" goto dx_sdk_dx9_30
  35. if /i "%2" == "-dx10" goto dx_sdk_dx10
  36. goto dx_sdk_end
  37. :dx_sdk_x360
  38. set DIRECTX_SDK_VER=x360.00
  39. set DIRECTX_SDK_BIN_DIR=x360xdk\bin\win32
  40. goto dx_sdk_end
  41. :dx_sdk_dx9_30
  42. set DIRECTX_SDK_VER=pc09.30
  43. set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx9_30
  44. goto dx_sdk_end
  45. :dx_sdk_dx10
  46. set DIRECTX_SDK_VER=pc10.00
  47. set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx10_40
  48. goto dx_sdk_end
  49. :dx_sdk_ps3
  50. set DIRECTX_SDK_VER=ps3
  51. set DIRECTX_SDK_BIN_DIR=ps3sdk\utilities
  52. goto dx_sdk_end
  53. :dx_sdk_end
  54. if "%1" == "" goto usage
  55. set inputbase=%1
  56. if /i "%3" == "-force30" goto set_force30_arg
  57. goto set_force_end
  58. :set_force30_arg
  59. set DIRECTX_FORCE_MODEL=30
  60. goto set_force_end
  61. :set_force_end
  62. if /i "%2" == "-x360" goto set_x360_args
  63. if /i "%2" == "-ps3" goto set_ps3_args
  64. if /i "%2" == "-game" goto set_mod_args
  65. if /i "%2" == "-nompi" set SDKArgs=-nompi
  66. goto build_shaders
  67. REM ****************
  68. REM USAGE
  69. REM ****************
  70. :usage
  71. echo.
  72. echo "usage: buildshaders <shaderProjectName> [-ps3 or -x360 or -dx10 or -game] [gameDir if -game was specified] [-nompi if -ps3 or -x360 was specified] [-source sourceDir]"
  73. echo " gameDir is where gameinfo.txt is (where it will store the compiled shaders)."
  74. echo " sourceDir is where the source code is (where it will find scripts and compilers)."
  75. echo "ex : buildshaders myshaders"
  76. echo "ex : buildshaders myshaders -game c:\steam\steamapps\sourcemods\mymod -source c:\mymod\src"
  77. echo "ex : buildshaders myshaders -x360 -nompi"
  78. echo.
  79. echo "PS3 specific parameters (mutually exclusive, and must directly follow the -ps3 parameter):"
  80. echo "-ps3debug - Generate PS3 debug information (only do this if you have an SSD - see the wiki)"
  81. echo "-ps3scheduleoptimization - Find optimal fragment shader compiler scheduler settings (this takes a LONG time!)"
  82. goto :end
  83. REM ****************
  84. REM X360 ARGS
  85. REM ****************
  86. :set_x360_args
  87. set x360_args=-x360
  88. set SDKArgs=
  89. if /i "%3" == "-nompi" set SDKArgs=-nompi
  90. set SHADERINCPATH=vshtmp9_360/... fxctmp9_360/...
  91. goto build_shaders
  92. REM ****************
  93. REM PS3 ARGS
  94. REM ****************
  95. :set_ps3_args
  96. set ps3_args=-ps3
  97. REM PS3 does not support MPI yet
  98. set SDKArgs=
  99. if /i "%3" == "-nompi" set SDKArgs=-nompi
  100. if /i "%3" == "-ps3scheduleoptimization" set ps3_additional_args=-ps3optimizeschedules
  101. if /i "%3" == "-ps3debug" set ps3_additional_args=-ps3debug
  102. set SHADERINCPATH=vshtmp9_ps3/... fxctmp9_ps3/...
  103. goto build_shaders
  104. REM ****************
  105. REM MOD ARGS - look for -game or the vproject environment variable
  106. REM ****************
  107. :set_mod_args
  108. if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile
  109. set ChangeToDir=%sourcesdk%\bin
  110. if /i "%4" NEQ "-source" goto NoSourceDirSpecified
  111. set SrcDirBase=%~5
  112. REM ** use the -game parameter to tell us where to put the files
  113. set targetdir=%~3\shaders
  114. set SDKArgs=-nompi -game "%~3"
  115. if not exist "%~3\gameinfo.txt" goto InvalidGameDirectory
  116. goto build_shaders
  117. REM ****************
  118. REM ERRORS
  119. REM ****************
  120. :InvalidGameDirectory
  121. echo -
  122. echo Error: "%~3" is not a valid game directory.
  123. echo (The -game directory must have a gameinfo.txt file)
  124. echo -
  125. goto end
  126. :NoSourceDirSpecified
  127. echo ERROR: If you specify -game on the command line, you must specify -source.
  128. goto usage
  129. goto end
  130. :NoShaderCompile
  131. echo -
  132. echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin
  133. echo -
  134. goto end
  135. REM ****************
  136. REM BUILD SHADERS
  137. REM ****************
  138. :build_shaders
  139. rem echo --------------------------------
  140. rem echo %inputbase%
  141. rem echo --------------------------------
  142. REM make sure that target dirs exist
  143. REM files will be built in these targets and copied to their final destination
  144. if not exist %shaderDir% mkdir %shaderDir%
  145. if not exist %shaderDir%\fxc mkdir %shaderDir%\fxc
  146. if not exist %shaderDir%\vsh mkdir %shaderDir%\vsh
  147. if not exist %shaderDir%\psh mkdir %shaderDir%\psh
  148. REM Nuke some files that we will add to later.
  149. if exist filelist.txt del /f /q filelist.txt
  150. if exist filestocopy.txt del /f /q filestocopy.txt
  151. if exist filelistgen.txt del /f /q filelistgen.txt
  152. if exist inclist.txt del /f /q inclist.txt
  153. if exist vcslist.txt del /f /q vcslist.txt
  154. if exist makefile.%inputbase%.copy del /f /q makefile.%inputbase%.copy
  155. REM ****************
  156. REM Revert any targets (vcs or inc) that are opened for integrate.
  157. REM ****************
  158. perl "%SrcDirBase%\devtools\bin\p4revertshadertargets.pl" %x360_args% %ps3_args% -source "%SrcDirBase%" %inputbase%
  159. REM ****************
  160. REM Generate a makefile for the shader project
  161. REM ****************
  162. perl "%SrcDirBase%\devtools\bin\updateshaders.pl" %x360_args% %ps3_args% -source "%SrcDirBase%" %inputbase%
  163. REM ****************
  164. REM Run the makefile, generating minimal work/build list for fxc files, go ahead and compile vsh and psh files.
  165. REM ****************
  166. rem nmake /S /C -f makefile.%inputbase% clean > clean.txt 2>&1
  167. echo Building inc files, asm vcs files, and VMPI worklist for %inputbase%...
  168. nmake /S /C -f makefile.%inputbase%
  169. REM ****************
  170. REM Copy the inc files to their target
  171. REM ****************
  172. if exist "inclist.txt" (
  173. echo Publishing shader inc files to target...
  174. perl %SrcDirBase%\devtools\bin\copyshaderincfiles.pl inclist.txt %x360_args% %ps3_args%
  175. )
  176. REM ****************
  177. REM Deal with perforce operations for inc files
  178. REM ****************
  179. if exist inclist.txt if not "%VALVE_NO_AUTO_P4_SHADERS%" == "1" (
  180. echo Executing perforce operations on .inc files.
  181. perl ..\..\devtools\bin\p4autocheckout.pl inclist.txt "Shader Auto Checkout INC" . %SHADERINCPATH%
  182. )
  183. REM ****************
  184. REM Add the executables to the worklist.
  185. REM ****************
  186. if /i "%DIRECTX_SDK_VER%" == "pc09.00" (
  187. rem echo "Copy extra files for dx 9 std
  188. echo %SrcDirBase%\..\game\bin\d3dx9_33.dll >> filestocopy.txt
  189. echo %SrcDirBase%\..\game\bin\d3dx9_43.dll >> filestocopy.txt
  190. echo %SrcDirBase%\..\game\bin\d3dx10_33.dll >> filestocopy.txt
  191. echo %SrcDirBase%\..\game\bin\d3dx10_43.dll >> filestocopy.txt
  192. echo %SrcDirBase%\..\game\bin\d3dcompiler_41.dll >> filestocopy.txt
  193. echo %SrcDirBase%\..\game\bin\d3dcompiler_43.dll >> filestocopy.txt
  194. )
  195. if /i "%DIRECTX_SDK_VER%" == "pc09.30" (
  196. echo %SrcDirBase%\..\game\bin\d3dx9_33.dll >> filestocopy.txt
  197. echo %SrcDirBase%\..\game\bin\d3dx9_43.dll >> filestocopy.txt
  198. echo %SrcDirBase%\..\game\bin\d3dx10_33.dll >> filestocopy.txt
  199. echo %SrcDirBase%\..\game\bin\d3dx10_43.dll >> filestocopy.txt
  200. echo %SrcDirBase%\..\game\bin\d3dcompiler_41.dll >> filestocopy.txt
  201. echo %SrcDirBase%\..\game\bin\d3dcompiler_43.dll >> filestocopy.txt
  202. )
  203. if /i "%DIRECTX_SDK_VER%" == "pc10.00" (
  204. echo %SrcDirBase%\..\game\bin\d3dx9_33.dll >> filestocopy.txt
  205. echo %SrcDirBase%\..\game\bin\d3dx9_43.dll >> filestocopy.txt
  206. echo %SrcDirBase%\..\game\bin\d3dx10_33.dll >> filestocopy.txt
  207. echo %SrcDirBase%\..\game\bin\d3dx10_43.dll >> filestocopy.txt
  208. echo %SrcDirBase%\..\game\bin\d3dcompiler_41.dll >> filestocopy.txt
  209. echo %SrcDirBase%\..\game\bin\d3dcompiler_43.dll >> filestocopy.txt
  210. )
  211. if /i "%DIRECTX_SDK_VER%" == "x360.00" (
  212. rem echo "Copy extra files for xbox360
  213. )
  214. if /i "%DIRECTX_SDK_VER%" == "ps3" (
  215. echo %SrcDirBase%\ps3sdk\utilities\libcgc.dll >> filestocopy.txt
  216. echo %SrcDirBase%\ps3sdk\utilities\sceshaderperf.dll >> filestocopy.txt
  217. echo %SrcDirBase%\ps3sdk\utilities\nvshaderperf.dll >> filestocopy.txt
  218. echo %SrcDirBase%\ps3sdk\utilities\nvshaderperf_rsx.dll >> filestocopy.txt
  219. if exist "%SrcDirBase%\materialsystem\stdshaders\ps3optimalschedules.bin" echo %SrcDirBase%\materialsystem\stdshaders\ps3optimalschedules.bin >> filestocopy.txt
  220. if exist "%ChangeToDir%\ps3compilelog.txt" move /Y "%ChangeToDir%\ps3compilelog.txt" "%ChangeToDir%\ps3compilelog_prev.txt"
  221. echo ***** Start of Log >> %ChangeToDir%\ps3compilelog.txt
  222. )
  223. echo %SrcDirBase%\%DIRECTX_SDK_BIN_DIR%\dx_proxy.dll >> filestocopy.txt
  224. echo %SrcDirBase%\..\game\bin\shadercompile.exe >> filestocopy.txt
  225. echo %SrcDirBase%\..\game\bin\shadercompile_dll.dll >> filestocopy.txt
  226. echo %SrcDirBase%\..\game\bin\vstdlib.dll >> filestocopy.txt
  227. echo %SrcDirBase%\..\game\bin\tier0.dll >> filestocopy.txt
  228. REM ****************
  229. REM Cull duplicate entries in work/build list
  230. REM ****************
  231. if exist filestocopy.txt type filestocopy.txt | perl "%SrcDirBase%\devtools\bin\uniqifylist.pl" > uniquefilestocopy.txt
  232. if exist filelistgen.txt if not "%dynamic_shaders%" == "1" (
  233. echo Generating action list...
  234. copy filelistgen.txt filelist.txt >nul
  235. rem %SrcDirBase%\devtools\bin\fxccombogen.exe <filelistgen.txt 1>nul 2>filelist.txt
  236. )
  237. REM ****************
  238. REM Execute distributed process on work/build list
  239. REM ****************
  240. set shader_path_cd=%cd%
  241. if exist "filelist.txt" if exist "uniquefilestocopy.txt" if not "%dynamic_shaders%" == "1" (
  242. echo Running distributed shader compilation...
  243. cd %ChangeToDir%
  244. echo %shadercompilecommand% -mpi_workercount %shadercompileworkers% -allowdebug -shaderpath "%shader_path_cd:/=\%" %x360_args% %ps3_args% %SDKArgs% %ps3_additional_args%
  245. %shadercompilecommand% -mpi_workercount %shadercompileworkers% -allowdebug -shaderpath "%shader_path_cd:/=\%" %x360_args% %ps3_args% %SDKArgs% %ps3_additional_args%
  246. if /i "%DIRECTX_SDK_VER%" == "ps3" (
  247. echo.
  248. echo // PS3 fragment shader statistics: =============================================
  249. echo // Log file location: "%ChangeToDir%\ps3compilelog.txt"
  250. ps3shaderoptimizer ps3compilelog.txt
  251. )
  252. cd %shader_path_cd%
  253. )
  254. REM ****************
  255. REM PC, 360, PS3 Shader copy
  256. REM Publish the generated files to the output dir using ROBOCOPY (smart copy) or XCOPY
  257. REM This batch file may have been invoked standalone or slaved (master does final smart mirror copy)
  258. REM ****************
  259. if not "%dynamic_shaders%" == "1" (
  260. if exist makefile.%inputbase%.copy echo Publishing shaders to target...
  261. if exist makefile.%inputbase%.copy perl %SrcDirBase%\devtools\bin\copyshaders.pl makefile.%inputbase%.copy %x360_args% %ps3_args%
  262. )
  263. REM ****************
  264. REM Deal with perforce operations for vcs files
  265. REM ****************
  266. if not "%dynamic_shaders%" == "1" if exist vcslist.txt if not "%VALVE_NO_AUTO_P4_SHADERS%" == "1" (
  267. echo Executing perforce operations on .vcs files.
  268. perl ..\..\devtools\bin\p4autocheckout.pl vcslist.txt "Shader Auto Checkout VCS" ../../../game/platform/shaders ../../../game/platform/shaders/...
  269. )
  270. REM ****************
  271. REM END
  272. REM ****************
  273. :end
  274. %TTEXE% -diff %tt_start%
  275. echo.