Split Work Graph shaders into multiple frequencies.
This is somewhat in anticipation of graphic nodes.
But also it is a replacement for using CFLAG_WorkgraphLocalNodes to differentiate nodes with local or global root signature.
#rb Yuriy.ODonnell
[CL 33146442 by jeremy moore in ue5-main branch]
The option bPreserveStorageInput of current version of SPIRV-Tools does not work as it used to and unused fragment shader inputs are now stripped by RemoveUnusedInterfaceVariablesPass.
This fix does not address this but instead disables the input location remapping of OpenGLShaderCompiler for fragment shaders so that even when inputs are stripped, the remaining inputs still have their original location indices that match the vertex shader outputs.
#rb carl.lloyd
[FYI] Laura.Hermanns
[CL 32974465 by florian penzkofer in ue5-main branch]
- Adds StructPackingPass to SPIRV-Tools which re-assigns all struct member offsets of the global cbuffer ("type.$Globals" when translated in DXC/SPIR-V) according to the std140 memory layout rules.
- Remove DXC rewriter from shader backends as the shader minifier can already handle the majority of dead code removal.
- Rebuilt DXC for Win64, Mac, Linux.
#jira UE-207703
#rnx
#rb Yuriy.ODonnell
[FYI] Dan.Elksnitis, JeanNoe.Morissette, Serge.Bernier, Florin.Pascu
[CL 32646612 by laura hermanns in ue5-main branch]
Add basic DX12 Work Graph support.
For this first pass there is no exposed RHI functionality for directly dispatching a work graph. Instead shader bundles have been extended to support a work graph based implementation.
Nanite compute materials now can use work graph shader bundles on D3D12 when r.Nanite.AllowWorkGraphMaterials and r.Nanite.Bundle.Shading are both set. Both of these default to off at the moment.
Also DataDrivenPlatformInfo now expose bSupportsWorkGraphs. This is false everywhere, but will be enabled for D3D12_SM6 as soon as we have the latest DXC shader compiler with lib_6_8 support submitted.
#rb Kenzo.Terelst, Yuriy.ODonnell
[CL 32196717 by jeremy moore in ue5-main branch]
- Removed unnecessary operator == and GetTypeHash() functions.
Refactor of FOpenGLLinkedProgram to improve code readability
- Moved loose global scope functions to be members.
- Removed FOpenGLLinkedProgramConfiguration, replaced with a TVariant Config field in the FOpenGLLinkedProgram which better packs memory, and configures the stages on construction.
- Store per-stage data in an FShaderStage object (in the Config), rather than separate C arrays.
- Removed public access to various fields, and made things const where possible.
- Removed unnecessary TMap caches: GetOpenGLUniformBlockLocations(), GetOpenGLUniformBlockBindings()
Remove "bindless textures" from OpenGL RHI
- Code path is not one we need to support anymore, and removing it simplifies the FOpenGLLinkedProgram class
Fix calls to FOpenGL::ProgramUniform4... in the following functions passing the GL shader object when the GL program is required.
- FOpenGLShaderParameterCache::CommitPackedGlobals
- FOpenGLShaderParameterCache::CommitPackedUniformBuffers
#rb Florin.Pascu
[CL 31871857 by luke thatcher in ue5-main branch]
This affects Vulkan, Metal, GLES, and SPIR-V based platform backends.
Warnings will not be treated as errors for intermediate shader code, such as the one generated by the HLSL rewriter for dead-code removal.
#rnx
#rb carl.lloyd, massimo.tristano
[CL 31645356 by laura hermanns 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 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]
- Removing the need for COMPILER_DEFINE on GetResourceFromHeap and GetSamplerFromHeap
- FShaderParameterParser constructor now requires a FPlatformConfiguration object that each shader format can configure.
- FPlatformConfiguration::GenerateBindlessAccess allows each platform to generate the code for accessing a bindless resource or sampler.
- Added EShaderParameterParserConfigurationFlags to specify support for stable constant buffers and bindless.
- Moved EBindlessParameterMode into EShaderParameterParserConfigurationFlags::BindlessUsesArrays
- While moving things around, I was able to convert some TCHAR* uses to FStringView
#jira UE-166341
#rb mihnea.balta
[CL 29533376 by christopher waters in ue5-main branch]
OpenGL ES and Metal use framebuffer fetch.
Vulkan uses dual source blending.
For Vulkan and OpenGL ES there is a fallback shader permutation for drivers that don't support this. The fallback is the same as the existing solution that uses regular blending (i.e. looks different).
Others uses dual source blending and we force use of DXC for those shaders.
#rb Dmitriy.Dyomin, Florin.Pascu
[CL 29245271 by florian penzkofer in ue5-main branch]
- When generating Uniform Buffer HLSL code, a 'static const struct {} Name' was created which has been causing compiler issues off and on for years.
- When RemoveUniformBuffersFromSource removed said struct, it parsed the struct's structure to figure out how to translate UniformBuffer.Member into UniformBuffer_Member in code that accessed Uniform Buffers.
- Now, instead of a struct, a "UniformBuffer <Name>" declaration is created and filled with mappings from "UniformBuffer.Member" into the correct code.
- This allows ConstantBuffer objects to be used differently from cbuffer where the former generates "UniformBuffer.Member" and the latter generates "UniformBuffer_Member"
- This also allows resources to always be translated to "UniformBuffer_Member"
- Shader define 'PLATFORM_SUPPORTS_UB_STRUCT' is now 'PLATFORM_SUPPORTS_CONSTANTBUFFER_OBJECT' and will be set on shader formats that support ConstantBuffer<> objects.
- Removed lots of unused code from BindlessResources.ush
#jira UE-195103
#rb dan.elksnitis, jeannoe.morissette
[CL 28058373 by christopher waters in ue5-main branch]
- enable minifier deadstripping for OpenGL shader format; bytecode is a 100% match with this change on multiple tested projects so it seems safe to enable
- deprecate FOpenGLFrontend; nothing in available code appears to inherit from it anymore so the API appears unnecessary. this makes the OpenGL shader format more similar to others (which do not expose compilation functions as API)
#rb Jason.Nadro
#rb Laura.Hermanns
#rb Yuriy.ODonnell
[CL 27338803 by dan elksnitis in ue5-main branch]