Commit Graph

309 Commits

Author SHA1 Message Date
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
dd3eb79c6b [Shaders] Add special case to parsing HLSL semantics in cross-compilation pipeline.
There are special cases for semantics when the index is omitted and defaults to zero, e.g. "SV_ClipDistance0" or "SV_ClipDistance[0]".
In those cases, our HlslParser does not provide the semantic index so we have to handle it when re-ordering the interpolators in the DXBC backend.

#rnx
#rb Charles.deRousiers

[CL 34274363 by laura hermanns in ue5-main branch]
2024-06-11 09:27:37 -04:00
laura hermanns
5c17f21798 [Shaders] Fixed re-ordering of shader interpolators in D3D ES31 backend.
When cross-compiling HLSL 2021 to HLSL 2018 for D3D11, DXC/SPIRV-Cross re-arrange the vertex/pixel interpolators in a way that can cause mismatches in the PSO.
The previous method to re-order shader interpolators was to just search the source for their variable declaration semantics, but that search can confuse semantics like TEXCOORD1 with TEXCOORD10.

This change includes two fixes:
1. The new approach parses the semantics and match the entire name, not just searching for the presence of the respective semantic identifier.
2. Always declare system value semantics such as SV_Position after user-defined semantics in case they are not used in the pixel shader to preserve the DXBC register assignments.

This fixes issues with Substrate as we have to cross-compile lots of shaders for D3D11 and some ES31 preview platforms.

#jira UE-214192
#rnx
#rb Jason.Nadro

[CL 34200377 by laura hermanns in ue5-main branch]
2024-06-07 09:38:41 -04:00
arciel rekman
7818ba6bae Fix reflection data unnecessarily kept in compiled PCD3D_SM6 shaders.
- Found while investigating compressed size (by FabianG), seemst to have been that way since 22233889. Shader size down significanty, to about  30-40% of the previous (both disk size and the runtime footprint).

#rb christopher.waters, dan.elksnitis, Laura.Hermanns

[CL 34155347 by arciel rekman in ue5-main branch]
2024-06-06 09:37:28 -04:00
carl lloyd
d64722152b RHI Validation
- Removed reliance on ShaderParameterParser for most platforms as it doesn't always parse parameters

#rb Luke.Thatcher

[CL 33822449 by carl lloyd in ue5-main branch]
2024-05-22 04:15:09 -04:00
florian penzkofer
f45f20f45b Fix fatal error when using Editor Preview
#jira UE-215384
#rb dan.elksnitis, Laura.Hermanns, Yuriy.ODonnell

[CL 33792687 by florian penzkofer in ue5-main branch]
2024-05-21 09:36:25 -04:00
Yuriy ODonnell
29ef258f59 Support GPU diagnostic buffer binding when using static root signature
#rb graham.wihlidal
#jira none

[CL 33634764 by Yuriy ODonnell in ue5-main branch]
2024-05-14 15:13:55 -04:00
kenzo terelst
3df923dab2 - Add FShaderBindingLayout as RenderCore wrapper for FRHIShaderBindingLayout which can also cache static uniform buffer declerations used during shader code gen
- Add option for ShaderType to declare which FShaderBindingLayout needs to be used for shader gen and runtime binding
- Add helper function to generate FShaderBindingLayoutContainer from array of uniform buffers and EShaderResourceTableFlags (only supports bindless mode right now)
- Serialize the FRHIShaderBindingLayout in FShaderCompilerEnvironment so it can be used by the shader compiler backends
- FShaderBindingLayout can add required symbols to the FShaderCompilerInput which shouldn't be dead code eliminated (required for Shader resource table building)
- Serialize the hash of RHIShaderResourceTable in the platform specific shader binary data so it can be used during runtime RTPSO validation (all shaders in the RTPSO need the same RHIShaderResourceTable)
- Renamed pRootSignaure member to RootSignature (style guide)

#jira UE-212347

[CL 33624453 by kenzo terelst in ue5-main branch]
2024-05-14 04:49:23 -04:00
jonathan bard
f4d3ad0c59 Dump internal FXC compiler warnings when FXC fails to compile but DXC manages to, so that the user can know what failed and eventually correct it or at least make an informed decision about whether to bypass the error using DXC pre-compilation
#rb Laura.Hermanns

[CL 33296329 by jonathan bard in ue5-main branch]
2024-04-29 06:02:19 -04:00
steve robb
92463911c8 Fixed mismatched printf format arguments.
#rb brandon.schaefer

[CL 33264801 by steve robb in ue5-main branch]
2024-04-26 11:02:47 -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
christopher waters
cb17f328e6 Unifying bindless code generation.
- Array-based bindless (Vulkan) only needed one more piece of data to use "GenerateBindlessAccess"
- Now all bindless shader platforms will generate a getter function for each bindless resource/sampler.

#rb dan.elksnitis, jeannoe.morissette

[CL 32375983 by christopher waters in ue5-main branch]
2024-03-20 14:41:02 -04:00
matanshukry
4de594b05f [DXC] DXC release-1.8.2403 update; Re-introduce CL 32167265 with fixes.
This re-introduced the backed-out CL for the DXC update including fixes to detect derivitive opcodes in DXIL containers and a null-pointer fix in the DXIL code generator (GitHub draf #6411).
Only the Windows binary is updated since no other platform uses the DXIL code generator. Linux and Mac binary updates will follow in a separate CL.

Also replaced DXIL binary with v1.8 obtained from https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.8.2403

#jira UE-203636
#rb Graham.Wihlidal, Jeremy.Moore
[FYI] Bob.Tellez, Dan.Elksnitis

[CL 32257727 by matanshukry in ue5-main branch]
2024-03-14 16:16:24 -04:00
christopher waters
63dcb443e0 Removing LogD3D11ShaderCompiler and LogD3D12ShaderCompiler in favor of LogD3DShaderCompiler.
#rb Laura.Hermanns

[CL 32250370 by christopher waters in ue5-main branch]
2024-03-14 13:29:58 -04:00
christopher waters
5a8c01556a Adding proper SM6.8 support to ShaderFormatD3D
- Only WorkGraph shaders use this currently.
- SM6.8 needs to set the __SHADER_TARGET_MAJOR and __SHADER_TARGET_MINOR defines
- Changing some logic that was SM6.6 specific to now allow the higher shader model.

#rb Jeremy.Moore

[CL 32220197 by christopher waters in ue5-main branch]
2024-03-13 13:48:54 -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
bob tellez
786acc30b5 [Backout] - CL32167265
[FYI] Laura.Hermanns
Original CL Desc
-----------------------------------------------------------------
[DXC] DXC release-1.8.2403 update

This is the last CL of the DXC update including the binary files and API headers. The other CLs including all source changes are:
- 32164743 SPIRV-Headers
- 32166600 SPIRV-Tools
- 32165724 SPIRV-Cross
- 32165890 DirectXShaderCompiler
- 32165937 ShaderConductor
- 32165762 googletest
- 32165815 cxxopts

#jira UE-203636
#rb Graham.Wihlidal, Carl.Lloyd, JeanNoe.Morissette, Florin.Pascu, Serge.Bernier
[FYI] Dan.Elksnitis, Jason.Nadro, Yuriy.Odonnell, Jeremy.Moore

[CL 32172513 by bob tellez in ue5-main branch]
2024-03-11 23:38:27 -04:00
laura hermanns
183be489c9 [DXC] DXC release-1.8.2403 update
This is the last CL of the DXC update including the binary files and API headers. The other CLs including all source changes are:
- 32164743 SPIRV-Headers
- 32166600 SPIRV-Tools
- 32165724 SPIRV-Cross
- 32165890 DirectXShaderCompiler
- 32165937 ShaderConductor
- 32165762 googletest
- 32165815 cxxopts

#jira UE-203636
#rb Graham.Wihlidal, Carl.Lloyd, JeanNoe.Morissette, Florin.Pascu, Serge.Bernier
[FYI] Dan.Elksnitis, Jason.Nadro, Yuriy.Odonnell, Jeremy.Moore

[CL 32167352 by laura hermanns in ue5-main branch]
2024-03-11 17:55:53 -04:00
graham wihlidal
831fff0c59 Added CFLAG_ShaderBundle and decorated Nanite CS materials with it (some platforms can use this to build relevant data structures for internal bundle implementations).
#rb yuriy.odonnell
[REVIEW] https://p4-swarm.epicgames.net/reviews/32011926

[CL 32012726 by graham wihlidal in ue5-main branch]
2024-03-05 00:40:11 -05:00
christopher waters
62f06a4bb7 Disabling PLATFORM_SUPPORTS_CONSTANTBUFFER_OBJECT for now.
We can't get usage information from reflection with this enabled, mainly for bindless, so we'll need to revisit this later.

#rb Laura.Hermanns

[CL 31741310 by christopher waters in ue5-main branch]
2024-02-22 18:32:53 -05:00
christopher waters
68308c5193 Shader statistics
- Adding utility function for easier additions to FShaderCompilerOutput::ShaderStatistics
- Simplified existing uses of FShaderCompilerOutput::ShaderStatistics
- Reworked D3D compilation to allow DXC vs FXC to specify their different shader limits.
- Adding Shader Statistics for D3D SamplerState and Resource usages.
- Adding Shader Statistics for D3D SM6.6 bindless resource usages.

#rb Jason.Nadro, Laura.Hermanns

[CL 31740056 by christopher waters in ue5-main branch]
2024-02-22 18:16:34 -05:00
yuriy odonnell
01419a8913 Add strongly typed EShaderOptionalDataKey to access shader optional data instead of adhoc characters
#rb carl.lloyd, christopher.waters, Colton.Daniels

[CL 30572888 by yuriy odonnell in ue5-main branch]
2024-01-11 13:36:32 -05:00
chris kulla
2cd6fd99d1 Shader Compiler - Propagate filename to dxc command line instead of using the same dummy name (zzz) for all shaders.
This is helpful when using a profiler such as nSight

#rb christopher.waters

[CL 30514398 by chris kulla in ue5-main branch]
2024-01-09 15:23:12 -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