- set bCachePreprocessed member to true by default instead of false; the only impact of this is to enable this feature for niagara VM shaders which were previously still preprocessing in SCW unintentionally
- add a CFLAG to disable the source stripping process that runs at the end of preprocessing if preprocessed job cache is enabled (and further a cvar to disable this process across the board for debug workflow purposes)
- always disable the stripping for vectorVM shaders; this backend blows up if the shader source contains comments, and some minimal comments are added as part of the stripping process
- change condition which determines whether to run preprocessing in the compile step to check the preprocess output bSucceeded flag instead of bCachePreprocessed; this works in both SCW directcompile mode and normal execution without needing the former to explicitly set that flag to false (since it's now true by default)
#rb Laura.Hermanns
[CL 32759519 by dan elksnitis in ue5-main branch]
- add FShaderSource class which wraps source as populated by preprocessing and subsequently accessed by compilation and other debug features; this class automatically inserts zeroed padding such that 16-byte-wide SIMD string comparison operations do not require a non-SIMD tail to process any overhang.
- add typedefs for the string/view/character types and update preprocessing code to use these typedefs instead of the explicit types
- add explicit if constexprs in minifier code around char width to disable simd optimizations for char width != 2 (and subsequently skip the non-simd tail if char width == 2 since FShaderSource automatically adds the required padding)
#rb Jason.Nadro, Yuriy.ODonnell
[CL 30358137 by dan elksnitis in ue5-main branch]
- move sequence of preprocessing steps out of ShaderPreprocessor module and into UE::ShaderCompilerCommon::ExecuteShaderPreprocessingSteps; the former is now explicitly just the low-level preprocessor lib
- add an implementation of PreprocessShader in FBaseShaderFormat so backends which have no custom code to execute as part of preprocessing can just automatically inherit this implementation, and fix up such backends to eliminate now-unnecessary overrides
#rb christopher.waters, Laura.Hermanns
[CL 30178136 by dan elksnitis in ue5-main branch]
- never append the environment defines as commented code to the source used for further preprocessing/compilation; instead only append it to the debug USF
- strip comments after loading the debug usf in direct compile mode as some backends expect comments to have already been removed and the extra ones we add to the debug dump cause them to barf
- change all #if 0s in the debug usf to block comments instead so the above can strip them (said backends also don't like preprocessor directives left in the file)
#rb Jason.Nadro, rob.krajcarski
[CL 30161438 by dan elksnitis in ue5-main branch]
- move uniform buffer cleanup and dead stripping into ShaderPreprocessor module's PreprocessShader function
- add "required symbols" to compiler input struct to specify additional symbols to keep during minification aside from those specified by the entrypoint; modify API such that both an entry point string and additional symbols can be specified (to avoid each backend needing to manually parse the compound RT entry point string)
- make use of ModifyShaderCompilerInput in all backends to set additional defines and required symbols on input struct up front; only use the AdditionalDefines map in cases where it's actually necessary
- remove the various per-platform defines for enabling minifier, no longer required now that this has been rolled out for all backends
- fix SCW directcompile mode; this had rotted due to pieces of the FShaderCompilerEnvironment having been added that weren't explicitly serialized to either cmdline or in the shader source. this now serializes as a base64 string written inside the USF containing all portions of the environment required for compilation (using the same serialization function as is used to write/read the SCW input file)
- use a debug flag for indicating we're in "direct compile" mode and should load the debug USF off disk, rather than the poorly named "bSkipPreprocessedCache" (this name is both inaccurate and also confusing due to the addition of the preprocessed job cache)
- modify platform "force wave32" mechanism to use a pragma directive to set a compiler define, instead of doing string replacement in the preprocessed source
- add a view version of the RT entrypoint parsing to use in preprocessing, note that other paths still need to construct fstrings due to further manipulation so keeping the FString path around too
- clean up backends manually checking the "directcompile" cmdline arg
#rb christopher.waters, Yuriy.ODonnell
#rb Chris.Waters
#rb Laura.Hermanns
[CL 30023082 by dan elksnitis in ue5-main branch]
- the xcode and cmake projects were updated to use cpp17
- a variable was renamed in opt_copy_propagation_elements to fix a compilation error on linux
- remove the register keyword from the autogenerated lexer code using a define
- added and modified scripts to fix the compilation process
#rb Laura.Hermanns
[CL 29925957 by wouter dek in ue5-main branch]
- Comparing A==B will return true for NaN depending on the FP mode, so we now compare if both values are finite before comparing for equality.
- This does not fix the source of the error, but will stop all subsequent float values being set to NaN
#rb rob.krajcarski
#jira UE-194597
[CL 27694043 by stu mckenna in ue5-main branch]
- Remove the condition causing SCW to automatically exit after a single job if HLSLcc was used. This doesn't appear to be beneficial; HLSLcc uses a lot of memory but does not appear to leak it, so we're wasting time spinning up new processes unnecessarily here. This allows us to deprecated the associated field in the compiler output and function in IShaderFormat.
- Strip out compiler invocations stats; this was not accurate in some cases and it was decided after discussion that at this point the effort to fix the problems was not worth the utility we get from it.
#rb Jason.Nadro
#rb Laura.Hermanns
[CL 26256933 by dan elksnitis in ue5-main branch]
if (Condition)
{
Foo = Bar; // this would have been replaced with: branch_flattened_temp0 = Bar;
Foo2 = Foo; // this would have been replaced with: branch_flattened_temp1 = Foo; this should have been replaced by:
branch_flattened_temp1 = branch_flattened_temp0;
}
#jira UE-164327
#rb simon.tovey
#preflight 632ddb75e23e50651b95cca4
[CL 22164425 by rob krajcarski in ue5-main branch]
Headers are updated to contain any missing #includes needed to compile and #includes are sorted. Nothing is removed.
#ushell-cherrypick of 21064294 by bryan.sefcik
#jira
#preflight 62d5c2111062f2e63015e598
#ROBOMERGE-OWNER: bryan.sefcik
#ROBOMERGE-AUTHOR: bryan.sefcik
#ROBOMERGE-SOURCE: CL 21155249 via CL 21158121 via CL 21161259
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)
[CL 21182053 by bryan sefcik in ue5-main branch]
A = GetFirstValue();
B = A;
A = GetSecondValue();
C = A; // <-- this would get GetSecondValue() assigned to C instead of GetFirstValue()
Adds an SSA pass to help reduce overwriting registers, adds logic to remove self assignments, and adds logic to stop propagating when values are dirtied
From a sampling of scripts, about 2% are changed (where 1-3 unnecessary ops have been deleted).
#rb simon.tovey
#preflight 62b0d63c8e03312ad83a0c51
#jira UE-148892
[CL 20756957 by rob krajcarski in ue5-main branch]