Commit Graph

46 Commits

Author SHA1 Message Date
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
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
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
Marc Audy
68150e0be7 Merge UE5/Release-Engine-Staging to UE5/Main @ 14611496
This represents UE4/Main @ 14594913

[CL 14612291 by Marc Audy in ue5-main branch]
2020-10-29 13:38:15 -04:00
christopher waters
1fefa64f2f Updating "D3D10" type usages to the version agnostic "D3D"
#jira none
#rb Arciel.Rekman, Lukas.Hermanns

[CL 14397141 by christopher waters in ue5-main branch]
2020-09-25 12:21:25 -04:00
Marcus Wassmer
3b81cf8201 Merging using //UE5/Main_to_//UE5/Release-Engine-Staging @14384769
autoresolved files
#rb none

[CL 14384911 by Marcus Wassmer in ue5-main branch]
2020-09-24 00:43:27 -04:00
Marc Audy
11f5b21210 Merging //UE5/Release-Engine-Staging @ 13752110 to Main (//UE5/Main)
#rnx

[CL 13753156 by Marc Audy in ue5-main branch]
2020-06-23 18:40:00 -04:00
rob krajcarski
af02155770 Tweak D3d shader compiler to cleanly report error with too many UAV's rather than issuing a fatal error
#jira none
#rb stu.mckenna
#lockdown Marcus.Wassmer

#ROBOMERGE-SOURCE: CL 12928868 in //UE4/Release-4.25/... via CL 12928880 via CL 12928942
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v682-12900288)

[CL 12928955 by rob krajcarski in Main branch]
2020-04-20 14:24:11 -04:00
rolando caloca
369d6d8b29 UE4.25 - Compile fix
#rb none
#rnx
#jira
#lockdown Marcus.Wassmer

#ROBOMERGE-SOURCE: CL 12874478 in //UE4/Release-4.25/... via CL 12874480 via CL 12874484
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v681-12776863)

[CL 12874493 by rolando caloca in Main branch]
2020-04-16 18:06:51 -04:00
rolando caloca
d1c7cbbd16 UE4.25 - Disambiguates crashes from inside a platform shader compiler
#rb Lukas.Hermanns
#rnx
#jira UE-79375
#lockdown Marcus.Wassmer

#ROBOMERGE-SOURCE: CL 12872434 in //UE4/Release-4.25/... via CL 12872446 via CL 12872449
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v681-12776863)

[CL 12872452 by rolando caloca in Main branch]
2020-04-16 16:36:56 -04:00
eric mcdaniel
6215a145a2 Remove shader compilation flag CFLAG_SkipOptimizationsDXC
- this was added to aid DXC bring up and is no longer needed
  - there are no active references

#rb David.Harvey
#jira none
#rnx
#ushell-cherrypick of 12599316 by eric.mcdaniel

#ROBOMERGE-SOURCE: CL 12754507 in //UE4/Release-4.25Plus/... via CL 12783839
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v681-12776863)

[CL 12786352 by eric mcdaniel in Main branch]
2020-04-14 16:52:50 -04:00
eric mcdaniel
d04fb9c062 Add cvar to disable shader validation errors
- add support for disabling shader validation
    - UE flag already existed but didn't result in additional args being given to the shader compiler
      - D3D shader compiler now respects the flag
    - added new cvar r.Shaders.Validation to drive this globally
      - enabled by default

#rb David.Harvey
#jira none
#ushell-cherrypick of 12081058 by eric.mcdaniel

#ROBOMERGE-SOURCE: CL 12726824 in //UE4/Release-4.25Plus/... via CL 12781742
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v681-12776863)

[CL 12782558 by eric mcdaniel in Main branch]
2020-04-14 13:41:04 -04:00
juan canada
d3ed04f590 Added support for static samplers for D3D12 shaders compiled with DXC for PC.
#rb Rolando.Caloca
#jira none


#ushell-cherrypick of 12581778 by Yuriy.ODonnell

#ROBOMERGE-SOURCE: CL 12624927 in //UE4/Release-4.25/... via CL 12624931 via CL 12624933
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v675-12543919)

[CL 12624936 by juan canada in Main branch]
2020-04-06 13:21:00 -04:00