Commit Graph

240 Commits

Author SHA1 Message Date
dmitriy dyomin
de2b738ffa Mobile: Added an option to not use PLS and FBF extension on Android OpenGL
Enabling it will force a multipass rendering where GBuffer and SceneColor are resolved to a system memory

[CL 36327269 by dmitriy dyomin in 5.5 branch]
2024-09-17 01:36:59 -04:00
JayLu2000
e04a0ccdd5 PR #12150: [MetaXR]: Integrate Adreno Offline Shader Compiler into UE
#jira UE-220969
#rnx
#rb Dmitriy.Dyomin, Florin.Pascu

[CL 35369646 by JayLu2000 in ue5-main branch]
2024-08-07 11:07:33 -04:00
laura hermanns
b40bd9d092 [Shaders] Remove unused platform specific identifiers from GLES shader backend.
#rnx
#rb brian.white, Florin.Pascu

[CL 35343031 by laura hermanns in ue5-main branch]
2024-08-06 11:52:26 -04:00
dan elksnitis
0320312a2b [Backout] - CL35053495
[FYI] dan.elksnitis
Original CL Desc
-----------------------------------------------------------------
[shaders]
- move population of output.target field into core code so each backend doesn't need to do it manually (do so before calling the compile function so any existing code expecting the output field to be set at any point during the compile process is unaffected)
- add a check in FShaderCompileJob::SerializeOutput and FShaderCompileJob::SerializeWorkerOutput that the FShaderTarget for a job output matches that of its input. This should catch cases of shaders with the wrong frequency being associated with jobs; further the callstack should indicate where this incorrect association is coming from (since SerializeOutput is called in different places for each cache path: duplicate in-flight jobs, jobs which hit in the in-memory job cache, and jobs which hit in the DDC cache, and SerializeWorkerOutput is only called when the job is read back from SCW output).

#rb Laura.Hermanns

[CL 35080902 by dan elksnitis in ue5-main branch]
2024-07-25 10:12:01 -04:00
dan elksnitis
ddbc683598 [shaders]
- move population of output.target field into core code so each backend doesn't need to do it manually (do so before calling the compile function so any existing code expecting the output field to be set at any point during the compile process is unaffected)
- add a check in FShaderCompileJob::SerializeOutput and FShaderCompileJob::SerializeWorkerOutput that the FShaderTarget for a job output matches that of its input. This should catch cases of shaders with the wrong frequency being associated with jobs; further the callstack should indicate where this incorrect association is coming from (since SerializeOutput is called in different places for each cache path: duplicate in-flight jobs, jobs which hit in the in-memory job cache, and jobs which hit in the DDC cache, and SerializeWorkerOutput is only called when the job is read back from SCW output).

#rb Laura.Hermanns

[CL 35053511 by dan elksnitis in ue5-main branch]
2024-07-24 10:09:55 -04:00
christopher waters
cfc6f343df Uniform Buffer improvements
- Moving various UB booleans into a flags enum.
- UB booleans could not be reasonably deprecated without incurring memory overhead, so this will break custom code that uses them.
- Adding UB flag to force the shader compilers to generate reflection for the UB members which are normally excluded from reflection.
- Adding UB flag that tells MeshCommands that a UB will be bound during pass drawing and that it doesn't need to be set via MDCs.
- New flags are not used in this CL, they are prerequisites for subsequent, larger changes.

#rb jeannoe.morissette

[CL 34356503 by christopher waters in ue5-main branch]
2024-06-13 17:59:13 -04:00
laura hermanns
a34925adb1 [Shaders] SPIRV-Tools pass rewrite (Re-introduced after backout of 34098261)
Interface variable scalar replacement pass rewrite (added as a new pass into spirv-opt, will replace existing one in future).

Things done so far:
- Rewritten to properly handle non-aggregate types and other tricky cases (both for Patch decorated variables and not)
- Matrix scalarization is now optional.
- More test cases added
- Path is now exposed as a command-line flag
- Fixed https://github.com/KhronosGroup/SPIRV-Tools/issues/4795

Few shaders contained loops, which were not unrolled, leading to the scalarization pass to fail. Loops were not unrolled due to "complex" condition expression. Those are changed to be accepted by the loop unroller (induction variable is the only lhs in the condition expression now).

This new pass is now always enabled for both Vulkan/GLES shaders for Android.
Multiple location remapping passes were removed: one was overriding another one results + not needed now due to arrays being removed by the scalarization pass.

#rb carl.lloyd, denys.mentiei
[FYI] Dmitriy.Dyomin, Allan.Bentham

[CL 34122278 by laura hermanns in ue5-main branch]
2024-06-05 09:24:38 -04:00
laura hermanns
434f0c3b84 [Backout] - CL34098261
[FYI] denys.mentiei
Original CL Desc
-----------------------------------------------------------------
[Shaders] SPIRV-Tools pass rewrite

Interface variable scalar replacement pass rewrite (added as a new pass into spirv-opt, will replace existing one in future).

Things done so far:
- Rewritten to properly handle non-aggregate types and other tricky cases (both for Patch decorated variables and not)
- Matrix scalarization is now optional.
- More test cases added
- Path is now exposed as a command-line flag
- Fixed https://github.com/KhronosGroup/SPIRV-Tools/issues/4795

Few shaders contained loops, which were not unrolled, leading to the scalarization pass to fail. Loops were not unrolled due to "complex" condition expression. Those are changed to be accepted by the loop unroller (induction variable is the only lhs in the condition expression now).

This new pass is now always enabled for both Vulkan/GLES shaders for Android.
Multiple location remapping passes were removed: one was overriding another one results + not needed now due to arrays being removed by the scalarization pass.

#rb carl.lloyd, Laura.Hermanns
[FYI] Dmitriy.Dyomin, Allan.Bentham

[CL 34107760 by laura hermanns in ue5-main branch]
2024-06-04 17:30:47 -04:00
denys mentiei
802971f9b4 [Shaders] SPIRV-Tools pass rewrite
Interface variable scalar replacement pass rewrite (added as a new pass into spirv-opt, will replace existing one in future).

Things done so far:
- Rewritten to properly handle non-aggregate types and other tricky cases (both for Patch decorated variables and not)
- Matrix scalarization is now optional.
- More test cases added
- Path is now exposed as a command-line flag
- Fixed https://github.com/KhronosGroup/SPIRV-Tools/issues/4795

Few shaders contained loops, which were not unrolled, leading to the scalarization pass to fail. Loops were not unrolled due to "complex" condition expression. Those are changed to be accepted by the loop unroller (induction variable is the only lhs in the condition expression now).

This new pass is now always enabled for both Vulkan/GLES shaders for Android.
Multiple location remapping passes were removed: one was overriding another one results + not needed now due to arrays being removed by the scalarization pass.

#rb carl.lloyd, Laura.Hermanns
[FYI] Dmitriy.Dyomin, Allan.Bentham

[CL 34100366 by denys mentiei in ue5-main branch]
2024-06-04 13:59:11 -04:00
dietmar hauser
244c0906af [Android] Fixing up GLSL shader compilation to once more allow usage of the OES External Texture extension
#jira UE-211495
#review 33604115

[CL 33653370 by dietmar hauser in ue5-main branch]
2024-05-15 05:46:03 -04:00
Wei Liu
949639e8d8 Fix the GBufferA format for the mobile deferred with pixel local storage .
#jira none

#rb Dmitriy.Dyomin

[CL 33598326 by Wei Liu in ue5-main branch]
2024-05-13 03:32:25 -04:00
jeremy moore
ba42a867b2 #jira UE-209673
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]
2024-04-22 14:59:28 -04:00
florian penzkofer
9dfb5d6f9c This fixes shader OpenGL ES shader link errors that prevent pretty much any project that use GL to work.
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]
2024-04-15 14:10:18 -04:00
laura hermanns
67217ad5ad [Shaders] Replace DXC rewriter with new SPIRV-Tools pass to pack "$Globals" cbuffer.
- 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]
2024-04-01 14:46:17 -04:00
matthew sorrels
b1018568f8 Fix crash when cooking Android OpenGLES on Linux by replacing swscanf based parser with native FindNextHLSLDefinitionOfType
#jira UE-205727
#rnx
#rb dan.elksnitis, Dmitriy.Dyomin, Florin.Pascu

[CL 32299451 by matthew sorrels in ue5-main branch]
2024-03-18 10:05:42 -04:00
christopher waters
cd0d92d515 Moving copy-pasted code into ShaderCompilerCommon.
#rb dan.elksnitis, jeannoe.morissette

[CL 32215186 by christopher waters in ue5-main branch]
2024-03-13 11:33:04 -04:00
jeremy moore
804418158d #jira UE-206245, UE-206247
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]
2024-03-12 18:42:09 -04:00
luke thatcher
f10a3f68ed OpenGL RHI changes to use the FShaderResourceTable in the base RHI shader type.
- 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]
2024-02-28 10:48:29 -05:00
laura hermanns
623800cc99 [Shaders] Forward CFLAG_WarningsAsErrors to DXC compiler in SPIR-V backends.
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]
2024-02-20 10:23:08 -05:00
christopher waters
eae2904886 Cleaning up some OpenGLDrv headers.
[CL 31495518 by christopher waters in ue5-main branch]
2024-02-14 17:04:19 -05:00
matthew sorrels
2cd19ec644 Fix shader compile problem on linux OpenGLES shader builds
#jira UE-205727
#rnx
#rb dan.elksnitis

[CL 31268756 by matthew sorrels in ue5-main branch]
2024-02-07 15:21:04 -05:00
laura hermanns
3e2c99ebce [Shaders] Remove Hlslcc form GL backend; Mobile renderer fully switched to DXC.
#rnx
#rb Carl.Lloyd, Dmitriy.Dyomin, Florin.Pascu
[FYI] Rolando.Caloca, Jason.Nadro

[CL 31258039 by laura hermanns in ue5-main branch]
2024-02-07 10:32:52 -05:00
carl lloyd
79eba84fae Fix for incorrect regex expression when renaming uniform buffers in OpenGL
#rb tim.doerries

[CL 30880719 by carl lloyd in ue5-main branch]
2024-01-25 05:14:40 -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
dan elksnitis
cc7c2c54f4 [shaders] shader format preprocessing cleanup & refactoring
- 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]
2023-11-30 15:56:34 -05:00