Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 57 additions & 9 deletions src/devtools/bin/process_shaders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,71 @@
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)][System.IO.FileInfo]$File,
[Parameter(Mandatory=$true)][string]$Version,
[Parameter(Mandatory=$false)][switch]$Force,
[Parameter(Mandatory=$false)][switch]$Dynamic,
[Parameter(Mandatory=$false)][System.UInt32]$Threads = 0,
[Parameter(Mandatory=$false)][System.UInt32]$Optimize = 3
[Parameter(Mandatory=$false)][int]$Threads = 0,
[Parameter(Mandatory=$false)][int]$Optimize = 3
)

if ($Version -notin @("20b","30","40","41","50","51")) { return }
# =====================================
# Validate input
# =====================================
if ($Version -notin @("20b","30","40","41","50","51")) {
return
}

# =====================================
# Resolve compilation parameters
# =====================================
$argsBase = @()
if ($Force) { $argsBase += "-force" }

if ($Threads -is [int] -and $Threads -gt 0) {
$ThreadsToUse = [Math]::Min($Threads, [int]$env:NUMBER_OF_PROCESSORS)
$argsBase += "-threads", $ThreadsToUse
}

$argsBase += "-ver", $Version
$argsBase += "-shaderpath", $File.DirectoryName

if ($Dynamic) {
$argsBase += "-dynamic"
} elseif ($Optimize -is [int]) {
$optVal = [Math]::Min([Math]::Max($Optimize, 0), 3)
$argsBase += "-optimize", $optVal
}

# =====================================
# Logging 1
# =====================================
$modeParts = @()
if ($Force) { $modeParts += "FORCE" }
if ($Dynamic) { $modeParts += "DYNAMIC" }
if (-not $Force -and -not $Dynamic) { $modeParts += "ON-DEMAND" }

$modeText = $modeParts -join " + "
$modeColor = if ($Force -or $Dynamic) { "Magenta" } else { "White" }

Write-Host "`nMode: $modeText`n" -ForegroundColor $modeColor

# =====================================
# Main shader compilation loop
# =====================================
$ShaderStart = Get-Date
foreach ($line in Get-Content $File) {
if ($line -match '^\s*$' -or $line -match '^\s*//') { continue }

$args = @()
if ($Dynamic) { $args += "-dynamic" }
if ($Threads -ne 0) { $args += "-threads"; $args += $Threads }
$args += "-ver"; $args += $Version
$args += "-shaderpath"; $args += $File.DirectoryName
if (-not $Dynamic) { $args += "-optimize"; $args += $Optimize }
# Build full args for this shader line
$args = @($argsBase)
$args += $line

# Invoke ShaderCompile
& "$PSScriptRoot\ShaderCompile" $args
}
$TotalTime = (Get-Date) - $ShaderStart

# =====================================
# Logging 2
# =====================================
Write-Host "`nShader compilation pass for $($File.Name) finished."
Write-Host ("Time elapsed: {0}h:{1:mm}m:{1:ss}s:{1:ff}ms`n" -f [int]$TotalTime.TotalHours, $TotalTime) -ForegroundColor Cyan
2 changes: 1 addition & 1 deletion src/game/client/swarm/c_asw_concommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ void rd_reset_level_and_promotion_f()

Msg( "All done, your level and promotion have been reset!\n" );
}
ConCommand rd_reset_level_and_promotion( "rd_reset_level_and_promotion", rd_reset_level_and_promotion_f, "Resets promotion (rank, level etc.)", FCVAR_DEVELOPMENTONLY );
ConCommand rd_reset_level_and_promotion( "rd_reset_level_and_promotion", rd_reset_level_and_promotion_f, "Resets promotion (rank, level etc.)", FCVAR_NOT_CONNECTED );

void asw_show_xp_f()
{
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/swarm_sdk_client.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ if ERRORLEVEL 1 exit 1
<DisableSpecificWarnings>26495;26812</DisableSpecificWarnings>
<WholeProgramOptimization>true</WholeProgramOptimization>
<OmitFramePointers>true</OmitFramePointers>
<IntelJCCErratum>true</IntelJCCErratum>
<IntelJCCErratum>false</IntelJCCErratum>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
Expand All @@ -253,7 +253,7 @@ if ERRORLEVEL 1 exit 1
<TargetMachine>MachineX86</TargetMachine>
<LinkErrorReporting>PromptImmediately</LinkErrorReporting>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/Brepro /SOURCELINK:..\..\sourcelink.json %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Brepro /SOURCELINK:..\..\sourcelink.json /IGNORE:4099 %(AdditionalOptions)</AdditionalOptions>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LargeAddressAware>true</LargeAddressAware>
<SetChecksum>true</SetChecksum>
Expand Down
2 changes: 1 addition & 1 deletion src/game/missionchooser/swarm_sdk_missionchooser.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ if ERRORLEVEL 1 exit 1
<WholeProgramOptimization>true</WholeProgramOptimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<IntelJCCErratum>true</IntelJCCErratum>
<IntelJCCErratum>false</IntelJCCErratum>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/swarm_sdk_server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ if ERRORLEVEL 1 exit 1
<WholeProgramOptimization>true</WholeProgramOptimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<IntelJCCErratum>true</IntelJCCErratum>
<IntelJCCErratum>false</IntelJCCErratum>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
50 changes: 45 additions & 5 deletions src/materialsystem/shaderlib/shaderlib_sdk.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectName>shaderlib</ProjectName>
<ProjectGuid>{1A1149D9-CB1B-BF85-19CA-C9C2996BFDE8}</ProjectGuid>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
Expand All @@ -45,13 +47,15 @@
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
<PreLinkEventUseInBuild>true</PreLinkEventUseInBuild>
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
<TargetName>shaderlib</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\Release\.\</OutDir>
<IntDir>.\Release\.\</IntDir>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
<PreLinkEventUseInBuild>true</PreLinkEventUseInBuild>
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
<TargetName>shaderlib</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent>
Expand Down Expand Up @@ -89,11 +93,11 @@
<ErrorReporting>Prompt</ErrorReporting>
</ClCompile>
<PreLinkEvent>
<Command>if exist ..\..\lib\public\shaderlib.lib attrib -r ..\..\lib\public\shaderlib.lib</Command>
<Command>if exist "$(TargetPath)" attrib -R "$(TargetPath)"</Command>
</PreLinkEvent>
<Lib>
<UseUnicodeResponseFiles>false</UseUnicodeResponseFiles>
<OutputFile>..\..\lib\public\.\shaderlib.lib</OutputFile>
<OutputFile>$(TargetPath)</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
<Xdcmake>
Expand All @@ -103,13 +107,25 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>$(OutDir)shaderlib.bsc</OutputFile>
</Bscmake>
<PostBuildEvent>
<Command>setlocal enabledelayedexpansion

set DestDir=..\..\lib\public

if not exist !DestDir! mkdir !DestDir!
if exist !DestDir!\$(TargetFileName) attrib -R !DestDir!\$(TargetFileName)
copy /Y $(TargetPath) !DestDir!\


</Command>
<Message>Publishing to target directory (..\..\lib\public\)...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
<Command />
</PreBuildEvent>
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand Down Expand Up @@ -140,13 +156,16 @@
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<CompileAs>CompileAsCpp</CompileAs>
<ErrorReporting>Prompt</ErrorReporting>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
<PreLinkEvent>
<Command>if exist ..\..\lib\public\shaderlib.lib attrib -r ..\..\lib\public\shaderlib.lib</Command>
<Command>if exist "$(TargetPath)" attrib -R "$(TargetPath)"
</Command>
</PreLinkEvent>
<Lib>
<UseUnicodeResponseFiles>false</UseUnicodeResponseFiles>
<OutputFile>..\..\lib\public\.\shaderlib.lib</OutputFile>
<OutputFile>$(TargetPath)</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
<Xdcmake>
Expand All @@ -156,6 +175,27 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>$(OutDir)shaderlib.bsc</OutputFile>
</Bscmake>
<CustomBuildStep>
<Outputs>
</Outputs>
<Message>
</Message>
<Command>
</Command>
</CustomBuildStep>
<PostBuildEvent>
<Command>setlocal enabledelayedexpansion

set DestDir=..\..\lib\public

if not exist !DestDir! mkdir !DestDir!
if exist !DestDir!\$(TargetFileName) attrib -R !DestDir!\$(TargetFileName)
copy /Y $(TargetPath) !DestDir!\


</Command>
<Message>Publishing to target directory (..\..\lib\public\)...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="..\..\vpc_scripts\source_lib_base.vpc" />
Expand Down
82 changes: 34 additions & 48 deletions src/materialsystem/stdshaders/buildsdkshaders.bat
Original file line number Diff line number Diff line change
@@ -1,66 +1,52 @@
@echo off
setlocal

rem Use dynamic shaders to build .inc files only
rem set dynamic_shaders=1
rem == Setup path to nmake.exe, from vc 2005 common tools directory ==
call "%VS80COMNTOOLS%vsvars32.bat"
REM ======================================
REM ==== PATH CONFIGURATIONS

rem ================================
rem ==== MOD PATH CONFIGURATIONS ===
REM == Setup path to nmake.exe, from vc common tools directory
call "G:\Program Files\Microsoft Visual Studio\18\Community\Common7\Tools\VsDevCmd.bat"

rem == Set the absolute path to your mod's game directory here ==
rem == Note that this path needs does not support long file/directory names ==
rem == So instead of a path such as "C:\Program Files\Steam\steamapps\mymod" ==
rem == you need to find the 8.3 abbreviation for the directory name using 'dir /x' ==
rem == and set the directory to something like C:\PROGRA~2\Steam\steamapps\sourcemods\mymod ==
set GAMEDIR=D:\Games\Steam\steamapps\common\asrdsymlink\reactivedrop
rem == Set the absolute path to your mod's game directory here
set GAMEDIR="G:\PENDRIVE\Steam\steamapps\common\Alien Swarm Reactive Drop\reactivedrop"

rem == Set the relative path to steamapps\common\Alien Swarm\bin ==
rem == As above, this path does not support long directory names or spaces ==
rem == e.g. ..\..\..\..\..\PROGRA~2\Steam\steamapps\common\ALIENS~1\bin ==
set SDKBINDIR=..\..\..\..\STEAME~1\steamapps\common\ALIENS~1\bin

rem == Set the Path to your mods root source code ==
rem this should already be correct, accepts relative paths only!
REM == Set the Path to your mods root source code
REM == "..\.." should already be correct, accepts relative paths only!
set SOURCEDIR=..\..

rem ==== MOD PATH CONFIGURATIONS END ===
rem ====================================

REM ==== PATH CONFIGURATIONS END
REM ======================================

REM ======================================
REM ==== SHADER BUILD CONFIGURATION

REM == Set force=1 to force shader recompilation
REM set FORCE=1

REM == Set dynamic_shaders=1 to build .inc files only
REM set dynamic_shaders=1

set TTEXE=..\..\devtools\bin\timeprecise.exe
if not exist %TTEXE% goto no_ttexe
goto no_ttexe_end
REM == Number of threads used by ShaderCompile:
REM == <= 0 or unset = all threads (default)
REM == > 0 = force specific number of threads
REM == Set to override the default behavior.
REM set THREADS=-1

:no_ttexe
set TTEXE=time /t
:no_ttexe_end
REM == Optimization level used by ShaderCompile:
REM == <= 0 = no optimization
REM == 1–2 = intermediate optimization
REM == >= 3 or unset = full optimization (default)
REM == Set to override the default behavior.
REM set OPTIMIZE=3

REM ==== SHADER BUILD CONFIGURATION END
REM ======================================

rem echo.
rem echo ~~~~~~ buildsdkshaders %* ~~~~~~
%TTEXE% -cur-Q
set tt_all_start=%ERRORLEVEL%
set tt_all_chkpt=%tt_start%
REM ======================================
REM ==== RUN

set BUILD_SHADER=call buildshaders.bat
set ARG_EXTRA=

%BUILD_SHADER% stdshader_dx9_20b -game %GAMEDIR% -source %SOURCEDIR%
%BUILD_SHADER% stdshader_dx9_20b_new -game %GAMEDIR% -source %SOURCEDIR%
%BUILD_SHADER% stdshader_dx9_30 -game %GAMEDIR% -source %SOURCEDIR% -force30


rem echo.
if not "%dynamic_shaders%" == "1" (
rem echo Finished full buildallshaders %*
) else (
rem echo Finished dynamic buildallshaders %*
)

rem %TTEXE% -diff %tt_all_start% -cur
rem echo.
%BUILD_SHADER% stdshader_dx9_20b -game %GAMEDIR% -source %SOURCEDIR%
%BUILD_SHADER% stdshader_dx9_20b_new -game %GAMEDIR% -source %SOURCEDIR%
%BUILD_SHADER% stdshader_dx9_30 -game %GAMEDIR% -source %SOURCEDIR% -force30
Loading
Loading