Commit Graph

22 Commits

Author SHA1 Message Date
Yuriy ODonnell
f204ba5ed7 Suppress false positive static analysis warning
#jira UE-208257

[CL 31850131 by Yuriy ODonnell in ue5-main branch]
2024-02-27 15:05:14 -05:00
Yuriy ODonnell
5b6b5d7c68 Handle line directives in ShaderMinifier ExtractBlock()
#rb Laura.Hermanns
#jira none

[CL 31714435 by Yuriy ODonnell in ue5-main branch]
2024-02-21 22:32:37 -05:00
jeremy moore
adb1c39e21 Add workgraph node support to shader minifier.
Missing functionality was that node functions can have a NodeID that is used to reference them.
The NodeID is set in an attribute on the function.
The fix is to always extract identifiers from function attributes.
This could be made more conservative by special casing to only NodeID function attributes. I'm not sure if the added complexity is worth it.
Note also that this works for node arrays, but doesn't remove out of array references when the NodeArraySize attribute is used. That is quite a special case though (different array slices from a shared array definition).
#rb Yuriy.ODonnell
#jira UE-206206

[CL 31277592 by jeremy moore in ue5-main branch]
2024-02-07 18:41:32 -05:00
yuriy odonnell
a09c23c4f6 ShaderMinifier - Use memstack for various temporary allocations
#jira UE-203990
#rb Jason.Nadro

[CL 30647996 by yuriy odonnell in ue5-main branch]
2024-01-16 17:45:20 -05:00
dan elksnitis
9bcbc546f7 [shaders] fix minifier test inputs to include simd padding
#rb Yuriy.ODonnell
#jira UE-203438

[CL 30567118 by dan elksnitis in ue5-main branch]
2024-01-11 09:14:09 -05:00
dan elksnitis
3dacd52109 [shaders] add support for single byte char path for minifier simd optimizations
#rb Yuriy.ODonnell
#jira UE-196110

[CL 30393653 by dan elksnitis in ue5-main branch]
2023-12-19 08:59:03 -05:00
dan elksnitis
a9037b25ed [shaders]
- 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]
2023-12-15 15:28:27 -05:00
yuriy odonnell
355a38075e Fix compile error on linux/mac due to indexing arrays with char type
#rb none

[CL 28699927 by yuriy odonnell in ue5-main branch]
2023-10-11 23:46:03 -04:00
yuriy odonnell
dd72ffe26c ShaderMinifier - Optimize BuildLineBreakMap, SkipUntilNonIdentifierCharacter, ExtractIdentifiers and few other bits
* Generate line directive map during parsing
* Use xxhash instead of cityhash
* Avoid FStringView operator [] in ExtractIdentifiers
* Use TArray Reset instead of Empty where appropriate
* Vectorize SkipUntilNonIdentifierCharacter
* Vectorize ExtractBlock
* Vectorize line ending search
* Use FString directly instead of FStringBuilderBase for the final output to avoid a copy

#rb christopher.waters
#rb jason.hoerner

[CL 28699609 by yuriy odonnell in ue5-main branch]
2023-10-11 23:32:28 -04:00
yuriy odonnell
eb793d3fb5 ShaderMinifier - Use inline implementations of string view Equals and StartsWith
* Also use TEXTVIEW instead of TEXT where possible
* ~1.5x speedup

#rb dan.elksnitis

[CL 28494884 by yuriy odonnell in ue5-main branch]
2023-10-05 08:26:07 -04:00
christopher waters
9b84b8accd Fixing enum handling in the shader minifier. Since the enum elements weren't marked as reachable identifiers, the minifier was considering the whole enum block unused.
#rb yuriy.odonnell

[CL 28438918 by christopher waters in ue5-main branch]
2023-10-03 19:32:26 -04:00
yuriy odonnell
d635588f1b ShaderMinifier - Don't skip keyword blocks when building ChunksByIdentifier (temporary workaround for an issue introduced in 28384399)
#rb christopher.waters

[CL 28417897 by yuriy odonnell in ue5-main branch]
2023-10-03 12:08:28 -04:00
yuriy odonnell
86d5bb7306 ShaderMinifier - Add basic support for global operator overloads
#rb christopher.waters

[CL 28417810 by yuriy odonnell in ue5-main branch]
2023-10-03 12:06:47 -04:00
christopher waters
c1487a0042 Adding typedef support to ShaderMinifier.
- Before this, every typedef and the code using them was being included in the final source.
- This was primarily affecting Bindless Resources where all bindless resources were included in the minified code even if they weren't used.

#rb yuriy.odonnell

[CL 28365749 by christopher waters in ue5-main branch]
2023-09-30 11:10:06 -04:00
christopher waters
5dc4ce553d Removing redundant line directives from Shader Minifier.
#rb yuriy.odonnell

[CL 27872540 by christopher waters in ue5-main branch]
2023-09-14 05:20:23 -04:00
Yuriy ODonnell
e5d4d76bed ShaderMinifier - Add basic namespace support
* Track namespaces for symbols
* Re-emit namespace scopes
* Conservatively include symbols from all namespaces in minified code (as if they were all global)
* Additional parsing work will be required to more accurately track used symbols based on active namespaces (i.e. handle `using` keyword, etc.)
* Added RemoveDeadCode() overload that takes an explicit list of required symbols instead of just an entry point name

#rb dan.elksnitis
#preflight 6398be5e35203bc7aa7f9b47

[CL 23494729 by Yuriy ODonnell in ue5-main branch]
2022-12-13 13:42:42 -05:00
Yuriy ODonnell
6911020bba ShaderMinifier - Fix handling of anonymous struct shader parameters
Declarations like `struct { uint Param; } Foo;` were previously incorrectly removed from code.

Also report explicit error when encountering 'namespace' keyword (which is currently unsupported)

#preflight 6387c5b1f213a116ebc18c5f
#rb dan.elksnitis

[CL 23343976 by Yuriy ODonnell in ue5-main branch]
2022-11-30 18:57:20 -05:00
Yuriy ODonnell
398f6e6d79 ShaderMinifier - Add an option to preserve comment lines
#rb dan.elksnitis
#preflight 63630eac522c8f7ab36344e0

[CL 22943808 by Yuriy ODonnell in ue5-main branch]
2022-11-03 02:13:18 -04:00
Yuriy ODonnell
f9824703c2 ShaderMinifier - Add basic test for MinifyShader, change SkipUntilNextLine to exclude new line character
#rb none (trivial)
#preflight 636068cde271e75dea59c739

[CL 22876523 by Yuriy ODonnell in ue5-main branch]
2022-10-31 21:34:29 -04:00
Yuriy ODonnell
9ab9403717 ShaderMinifier - Track and output line directives
#rb Jason.Nadro
#preflight 63406dd22a0a2c1ead8d1145

[CL 22405822 by Yuriy ODonnell in ue5-main branch]
2022-10-07 14:31:38 -04:00
Yuriy ODonnell
7e99cc870a ShaderMinifier - Ignore known resource types when looking for potential identifier names. Also add inclusion reason tracking for global variables.
#rb Jason.Nadro
#preflight 6322645eb602881e8e54709f

[CL 22029907 by Yuriy ODonnell in ue5-main branch]
2022-09-15 11:33:09 -04:00
Yuriy ODonnell
a18b223061 Groundwork for custom shader preprocessing step that removes unused code from shader source before compilation (not used yet by the shader pipeline)
#preflight 631bca62304480f8f8c2db54
#rb Jason.Nadro

[CL 21931128 by Yuriy ODonnell in ue5-main branch]
2022-09-09 19:33:52 -04:00