Commit Graph

125 Commits

Author SHA1 Message Date
christopher waters
a8185f9eb2 Removing validation skipping from the SM6.6 code path as it's a fully supported feature in our version of DXC.
#rb none
#jira none
#fyi graham.wihlidal, rune.stubbe

[CL 16756585 by christopher waters in ue5-main branch]
2021-06-23 10:14:39 -04:00
Lukas Hermanns
b5aafce030 Dump preprocessed shader source in log on D3DCompile exception.
#rb Rolando.Caloca
#fyi Michal.Valient, Mihnea.Balta, Luke.Thatcher, Arciel.Rekman, Chris.Bunner
#jira UE-114967
#rnx

[CL 16518546 by Lukas Hermanns in ue5-main branch]
2021-06-01 14:24:07 -04:00
Lukas Hermanns
b7a50e1d3d Report error code and addresses on D3DCompile exception.
#rb Rolando.Caloca
#jira UE-114967
#rnx

[CL 16437813 by Lukas Hermanns in ue5-main branch]
2021-05-24 14:02:01 -04:00
Arciel Rekman
d1e2a85fce Keep rewriting unused inputs until they stop changing (UE-115083)
- In a complex material, compiler may not be able to see through the code to discover all unused inputs.

E.g. first pass compilation says that input A is unused, but B and C are used. After we rewrite the code to remove A, the code is simpler and compiler is now able to see that B is also unused.

Since we pass the "used attributes" to the next stage, this creates a mismatch where vertex shader outputs only C, but pixel shader (rewritten based on the first pass results) expects B and C.

- The fixed code will check if the unused inputs changed, and if so, will go back and rewrite the code based on a more complete info.

- This fixes a bug that JonL ran into for which I haven't yet created a JIRA (will do before checkin).

#rb Ben.Ingram, Rolando.Caloca, Jason.Nadro
#review @Lukas.Hermanns, @Rolando.Caloca, @Ben.Ingram, @Jason.Nadro, @Kevin.Ortegren
#jira UE-115083

[CL 16312596 by Arciel Rekman in ue5-main branch]
2021-05-13 10:21:33 -04:00
Yuriy ODonnell
aa9e6a0c41 Added a basic implementation of assert in shaders for D3D12. Requires SM6 support which can be enabled through r.D3D12.AllowShaderModel6=1.
Example usage in a shader:

PLATFORM_ASSERT4(GroupThread > 4321, 0xDF7DC903, GroupThread, GroupIndex, GroupBase, asuint(123.456f));

Example GPU crash report output:

LogD3D12RHI: Error: [GPUBreadCrumb] Last tracked GPU operations:
LogD3D12RHI: Error: [GPUBreadCrumb]	3D Queue 0 - Begin: Frame 348 - Scene - ReflectionIndirect - RayTracingReflections - RayTracingDeferredReflectionsShade 957x466
LogD3D12RHI: Error: [GPUBreadCrumb]	Shader assertion failed! ID: 0xDF7DC903
LogD3D12RHI: Error: [GPUBreadCrumb]	Payload  [int32]: 416 42 172032 1123477881
LogD3D12RHI: Error: [GPUBreadCrumb]	Payload [uint32]: 416 42 172032 1123477881
LogD3D12RHI: Error: [GPUBreadCrumb]	Payload    [hex]: 0x000001A0 0x0000002A 0x0002A000 0x42F6E979
LogD3D12RHI: Error: [GPUBreadCrumb]	Payload  [float]: 0.000000 0.000000 0.000000 123.456001

This works through automatic diagnostic buffer binding in D3D12 RHI, which becomes available in *any* shader as a UAV.
Opens the door for arbitrary human-readable message output from any shader in the future.

PLATFORM_ASSERT macro is always enabled and available on supported platforms. It is intended to be a low-level mechanism for a higher-level check() that would be controlled via CVars.

#rb Christopher.Waters

[CL 16167404 by Yuriy ODonnell in ue5-main branch]
2021-04-30 08:37:35 -04:00
rob krajcarski
edf0afd436 Move D3DShaderCompiler fatal error over UAV counts to a shader compiler error.
#jira none
#rb lukas.hermanns

[CL 16074451 by rob krajcarski in ue5-main branch]
2021-04-21 11:31:10 -04:00
christopher waters
83f70197d3 Tessellation Removal: Removing RHI Hull/Domain shader types and enums.
#rb lukas.hermanns
#jira UE-94564
#preflight 607f2e11eb4f050001d4655e

[CL 16066223 by christopher waters in ue5-main branch]
2021-04-20 17:00:25 -04:00
graham wihlidal
b841d3cb41 Added shader compiler support for [noinline] where available. Informs compiler we want a subroutine created, which can be used to decrease register pressure in certain situations. Code is kept separate, and a set number of registers are used on each call. Should only be used with extensive profiling, as the default inlining behavior is usually best.
DXIL:  https://github.com/microsoft/DirectXShaderCompiler/blob/master/tools/clang/test/HLSLFileCheck/hlsl/functions/attribute/noinline.hlsl
SPIRV: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html (DontInline)

Shader code can now use NOINLINE, and also test if it maps to something useful with COMPILER_SUPPORTS_NOINLINE

#rb yuriy.odonnell
[FYI] rune.stubbe, brian.karis
#jira UETOP-1088
#lockdown nick.whiting

#ROBOMERGE-SOURCE: CL 16019442 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v789-15992632)

[CL 16022532 by graham wihlidal in ue5-main branch]
2021-04-15 12:09:16 -04:00
graham wihlidal
7b6ec4d476 Work in progress support for D3D12 Shader Model 6.6, specifying validator version, and workarounds to disable validation/signing until validator v1.6 is available that supports the 6.6 profile (requires developer mode and experimental features).
Disabled by default (guarded by USE_SHADER_MODEL_6_6).

Includes work done by Yuriy.

#rb yuriy.odonnell
#fyi brian.karis, christopher.waters, lukas.hermanns

[CL 15914077 by graham wihlidal in ue5-main branch]
2021-04-05 04:40:52 -04:00
mihnea balta
d5c41b1dec More cleanup for UE4 references.
#rb trivial
#rnx
#jira UE-111661 UE-111087 UE-111327 UE-111056 UE-111062 UE-111414 UE-111417 UE-111415 UE-111453 UE-111474 UE-111729

#ROBOMERGE-SOURCE: CL 15825946 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v785-15821902)

[CL 15829883 by mihnea balta in ue5-main branch]
2021-03-25 15:42:37 -04:00
christopher waters
1d0b1d44eb Initial support for Mesh and Amplification Shaders. These new shader types are an optional feature of the RHIs and are only enabled on PC D3D12 with Feature Level SM6.
#jira none
#rb emil.persson, graham.wihlidal, lukas.hermanns

[CL 15742432 by christopher waters in ue5-main branch]
2021-03-18 18:42:49 -04:00
Yuriy ODonnell
9219cb046d Differentiate between engine custom shader validation errors and real D3DCompileToDxil failures.
#rb Graham.Wihlidal

[CL 15732460 by Yuriy ODonnell in ue5-main branch]
2021-03-17 20:12:52 -04:00
christopher waters
bd8fabd199 Fixing UAVMask support.
- Removed OutputMask since nothing was using it anymore.
- Made UAVMask an optional output from FXC compiles, only d3d11 reads it.
- UAVMask now created from entire set of UAVs and not just UAVs in Uniform Buffers.

#jira none
#rb mihnea.balta

#ROBOMERGE-SOURCE: CL 15643920 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v779-15635321)

[CL 15643927 by christopher waters in ue5-main branch]
2021-03-08 15:13:56 -04:00
Arciel Rekman
751815e225 Load d3dcompiler_*.dll explicitly (UE-108348).
- This makes shader compilation predictable and resolves the issue with Incredibuild failing to run SCWs on systems without the library.

#rb Chris.Waters, Rolando.Caloca, Lukas.Hermanns
#review-15600065 @Chris.Waters, @Rolando.Caloca, @Lukas.Hermanns
#robomerge Release-5.0-EarlyAccess
#jira UE-108348

[CL 15600059 by Arciel Rekman in ue5-main branch]
2021-03-03 22:25:04 -04:00
chris kulla
fa647ce8c0 Add support for warning as errors when compiling shaders
This adds support for a new compilation flag that enables warnings as errors. Support was added for most of the main platforms. This feature has to opted into since many shaders currenntly contain small warnings, however this gives the ability for developpers to locally opt-in to this behavior to slowly sanitize code.

A global CVar: r.Shaders.WarningsAsErrors was also added, which will force every shader to be (re)built with this enabled for even more thorough checking.

#rb Jason.Nadro, Lukas.Hermanns, Rolando.Caloca

[CL 15383543 by chris kulla in ue5-main branch]
2021-02-10 20:30:29 -04:00
Yuriy ODonnell
2565f44a7b More verbose error message on DXC compile failure. Helps to differentiate shader compile errors from compiler crashes.
#rb Lukas.Hermanns

[CL 15349245 by Yuriy ODonnell in ue5-main branch]
2021-02-06 07:48:09 -04:00
Lukas Hermanns
a4dfdcd0ad Moved dxil.dll from DirectX folder into ShaderConductor binary folder and load dxil.dll manually to ensure it's always loaded from that location.
#rb Yuriy.ODonnell, Emil.Persson, Kenzo.Terelst
#fyi Mihnea.Balta, Rolando.Caloca, Graham.Wihlidal
#jira none
#rnx

[CL 15337426 by Lukas Hermanns in ue5-main branch]
2021-02-05 10:29:11 -04:00
Lukas Hermanns
a015b2c2e3 Use custom built dxc.exe for D3D shader compilation batch scripts.
#rb Yuriy.ODonnell
#fyi Graham.Wihlidal, Emil.Persson, Kenzo.Terelst
#jira none
#rnx

[CL 15284807 by Lukas Hermanns in ue5-main branch]
2021-02-02 17:12:57 -04:00
Yuriy ODonnell
8789e0bb07 Include shader compiler DLL version in FShaderFormatD3D/Vulkan::GetVersion(), similar to how it's done for other platforms.
#rb Lukas.Hermanns

[CL 15276007 by Yuriy ODonnell in ue5-main branch]
2021-02-01 18:54:58 -04:00
christopher waters
d1e9a0ce0b Adding ERHIFeatureLevel::SM6 and SP_PCD3D_SM6. Initially, both are disabled by default. The shader model is enabled with r.D3D12.AllowShaderModel6 and the feature level is only used when the shader model is enabled and the PC runtime supports 12_1 and SM6.5. The idea here is to raise these requirements to 12_2 and SM6.6 when those come online.
#jira none
#rb kenzo.terelst, arciel.rekman, lukas.hermanns, mihnea.balta, yuriy.odonnell

[CL 15222057 by christopher waters in ue5-main branch]
2021-01-27 16:08:00 -04:00
Marc Audy
ada7c144fa Merge //UE5/Release-Engine-Staging @14903491 to //UE5/Main
[CL 14906022 by Marc Audy in ue5-main branch]
2020-12-11 14:21:20 -04:00
christopher waters
c53cd84637 Make sure we use the checked in version of d3dcompiler_47.dll when loading the d3d shader format. Also make sure that version goes along in SN-DBS.
#jira none
#rb arciel.rekman, lukas.hermanns

[CL 14883307 by christopher waters in ue5-main branch]
2020-12-08 17:50:55 -04:00
zach bethel
0d7dc4d4ed Refactor of uniform buffer binding to allow for runtime selection of static or per-shader binding. This is a necessary precursor to moving the View uniform buffer to use static bindings on mesh passes; it is used in so many places that both binding models are required to preserve compatibility. Added validation to catch when a uniform buffer is bound using both methods at the same time. Added CVar to RHI transition validation to control whether to break in the debugger on a transition failure.
#rb christopher.waters

[CL 14873973 by zach bethel in ue5-main branch]
2020-12-07 17:42:32 -04:00
Lukas Hermanns
5acb4c83b6 DXC Update: SCW backends.
#rb none
#fyi Mihnea.Balta, Rolando.Caloca, Will.Damon, Jonas.Meyer, Michael.Sartain
#jira none
#rnx

[CL 14832278 by Lukas Hermanns in ue5-main branch]
2020-12-01 19:33:51 -04:00
Rolando Caloca
8c5dda23da UE5 - Proper fix for r.Shaders.KeepDebugInfo passing in the FRHIShader::ShaderName correctly
Initial fixes and tested on D3D11, D3D12 and Vulkan
Changed 'n' to FShaderCodeName::Key
Also added checks if trying to add optional shader data out of order
#rb Jonas.Meyer, Kenzo.Terelst, Mihnea.Balta

[CL 14816162 by Rolando Caloca in ue5-main branch]
2020-11-26 13:34:15 -04:00