UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Shader.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 Shader.h: Shader definitions.
5=============================================================================*/
6
7#pragma once
8
9#include "Algo/BinarySearch.h"
10#include "Containers/Array.h"
14#include "Containers/HashTable.h"
15#include "Containers/List.h"
16#include "Containers/Map.h"
17#include "Containers/Set.h"
20#include "CoreMinimal.h"
21#include "CoreTypes.h"
22#include "HAL/CriticalSection.h"
23#include "HAL/PlatformCrt.h"
24#include "HAL/ThreadSafeBool.h"
25#include "HAL/UnrealMemory.h"
26#include "Math/NumericLimits.h"
28#include "Misc/CString.h"
29#include "Misc/EnumClassFlags.h"
30#include "Misc/ScopeLock.h"
31#include "Misc/SecureHash.h"
32#include "RHI.h"
33#include "RHIDefinitions.h"
34#include "RHIMemoryLayout.h"
35#include "RenderResource.h"
41#include "ShaderCore.h"
43#include "ShaderParameters.h"
44#include "ShaderPermutation.h"
47#include "Templates/TypeHash.h"
48#include "Templates/UniquePtr.h"
51#include "UObject/NameTypes.h"
53
54#include <atomic>
55
56// For FShaderUniformBufferParameter
57
58#if WITH_EDITOR
60#endif
61
62class ITargetPlatform;
63class FCbFieldView;
64class FCbWriter;
75class FShader;
77class FShaderMapBase;
81class FShaderType;
88using FShaderMapAssetPaths = TSet<FName>; // Copied from ShaderCodeLibrary.h
89
91template<typename MetaShaderType>
93{
96
102
103 inline bool operator==(const TShaderTypePermutation& Other)const
104 {
105 return Type == Other.Type && PermutationId == Other.PermutationId;
106 }
107
108 inline bool operator!=(const TShaderTypePermutation& Other)const
109 {
110 return !(*this == Other);
111 }
112
113 friend inline uint32 GetTypeHash(const TShaderTypePermutation& Var)
114 {
116 }
117};
118
120
122
124template<typename MetaShaderType>
126{
127public:
129 {
130 int32 AL = FCString::Strlen(A.Type->GetName());
131 int32 BL = FCString::Strlen(B.Type->GetName());
132 if (AL == BL)
133 {
134 int32 StrCmp = FCString::Strncmp(A.Type->GetName(), B.Type->GetName(), AL);
135 if (StrCmp != 0)
136 {
137 return StrCmp > 0;
138 }
139 return A.PermutationId > B.PermutationId;
140 }
141 return AL > BL;
142 }
143};
144
146{
148public:
149 LAYOUT_FIELD(uint16, BaseIndex);
150
152
154 {
155 BaseIndex = InBaseIndex;
156 checkf(BaseIndex == InBaseIndex, TEXT("Tweak FShaderUniformBufferParameterInfo type sizes"));
157 }
158
160 {
161 Ar << Info.BaseIndex;
162 return Ar;
163 }
164
165 inline bool operator==(const FShaderUniformBufferParameterInfo& Rhs) const
166 {
167 return BaseIndex == Rhs.BaseIndex;
168 }
169
170 inline bool operator<(const FShaderUniformBufferParameterInfo& Rhs) const
171 {
172 return BaseIndex < Rhs.BaseIndex;
173 }
174};
175
177{
179public:
180 LAYOUT_FIELD(uint16, BaseIndex);
181 LAYOUT_FIELD(uint8, BufferIndex);
183
185
187 {
188 BaseIndex = InBaseIndex;
189 BufferIndex = InBufferIndex;
190 Type = InType;
191 checkf(BaseIndex == InBaseIndex && BufferIndex == InBufferIndex && Type == InType, TEXT("Tweak FShaderResourceParameterInfo type sizes"));
192 }
193
195 {
196 Ar << Info.BaseIndex;
197 Ar << Info.BufferIndex;
198 Ar << Info.Type;
199 return Ar;
200 }
201
202 inline bool operator==(const FShaderResourceParameterInfo& Rhs) const
203 {
204 return BaseIndex == Rhs.BaseIndex
205 && BufferIndex == Rhs.BufferIndex
206 && Type == Rhs.Type;
207 }
208
209 inline bool operator<(const FShaderResourceParameterInfo& Rhs) const
210 {
211 return BaseIndex < Rhs.BaseIndex;
212 }
213};
214
216{
218public:
219 LAYOUT_FIELD(uint16, BaseIndex);
221
223
225 {
226 BaseIndex = InBaseIndex;
227 Size = InSize;
228 checkf(BaseIndex == InBaseIndex && Size == InSize, TEXT("Tweak FShaderLooseParameterInfo type sizes"));
229 }
230
232 {
233 Ar << Info.BaseIndex;
234 Ar << Info.Size;
235 return Ar;
236 }
237
238 inline bool operator==(const FShaderLooseParameterInfo& Rhs) const
239 {
240 return BaseIndex == Rhs.BaseIndex
241 && Size == Rhs.Size;
242 }
243
244 inline bool operator<(const FShaderLooseParameterInfo& Rhs) const
245 {
246 return BaseIndex < Rhs.BaseIndex;
247 }
248};
249
251{
253public:
254 LAYOUT_FIELD(uint16, BaseIndex);
256
258
260
262 {
263 BaseIndex = InBufferIndex;
265 checkf(BaseIndex == InBufferIndex, TEXT("Tweak FShaderLooseParameterBufferInfo type sizes"));
266 }
267
269 {
270 Ar << Info.BaseIndex;
271 Ar << Info.Size;
272 Ar << Info.Parameters;
273 return Ar;
274 }
275
276 inline bool operator==(const FShaderLooseParameterBufferInfo& Rhs) const
277 {
278 return BaseIndex == Rhs.BaseIndex
279 && Size == Rhs.Size
280 && Parameters == Rhs.Parameters;
281 }
282
283 inline bool operator<(const FShaderLooseParameterBufferInfo& Rhs) const
284 {
285 return BaseIndex < Rhs.BaseIndex;
286 }
287};
288
314
315enum class ERayTracingPayloadType : uint32; // actual enum is defined in /Shaders/Shared/RayTracingPayloadType.h
318
321
329
330#define IMPLEMENT_RT_PAYLOAD_TYPE_CONCAT2( x, y ) x##y
331#define IMPLEMENT_RT_PAYLOAD_TYPE_CONCAT( x, y ) IMPLEMENT_RT_PAYLOAD_TYPE_CONCAT2( x, y )
332#define IMPLEMENT_RT_PAYLOAD_TYPE(PayloadType, PayloadSize) static FRegisterRayTracingPayloadTypeHelper IMPLEMENT_RT_PAYLOAD_TYPE_CONCAT(PayloadHelper, __COUNTER__) = FRegisterRayTracingPayloadTypeHelper(PayloadType, PayloadSize, nullptr);
333#define IMPLEMENT_RT_PAYLOAD_TYPE_FUNCTION(PayloadType, PayloadSizeFunction) static FRegisterRayTracingPayloadTypeHelper IMPLEMENT_RT_PAYLOAD_TYPE_CONCAT(PayloadHelper, __COUNTER__) = FRegisterRayTracingPayloadTypeHelper(PayloadType, 0u, PayloadSizeFunction);
334
336{
337public:
338 static RENDERCORE_API bool ArePlatformsCompatible(EShaderPlatform CurrentPlatform, EShaderPlatform TargetPlatform);
339
340 EShaderPlatform GetPlatform() const { return Platform; }
341
342 RENDERCORE_API void AddRef();
343 RENDERCORE_API void Release();
344 inline int32 GetNumRefs() const { return NumRefs.load(std::memory_order_relaxed); }
345
346 // FRenderResource interface.
347 RENDERCORE_API virtual void ReleaseRHI() override;
348
349 inline int32 GetNumShaders() const
350 {
351 return NumRHIShaders;
352 }
353
354 inline bool IsValidShaderIndex(int32 ShaderIndex) const
355 {
356 return static_cast<uint32>(ShaderIndex) < NumRHIShaders;
357 }
358
359 inline bool HasShader(int32 ShaderIndex) const
360 {
361 return RHIShaders[ShaderIndex].load(std::memory_order_acquire) != nullptr;
362 }
363
364 virtual uint32 GetShaderSizeBytes(int32 ShaderIndex) const;
365
367 {
368 /* no-op when not using shader library */
369 };
370
372 {
373 /* no-op when not using shader library */
374 };
375
376 virtual int32 GetGroupIndexForShader(int32 ShaderIndex) const
377 {
378 /* return invalid index when not using shader library */
379 return INDEX_NONE;
380 };
381
382 virtual int32 GetLibraryId() const
383 {
384 /* return invalid index when not using shader library */
385 return INDEX_NONE;
386 }
387
388 virtual int32 GetLibraryShaderIndex(int32 ShaderIndex) const
389 {
390 /* return invalid index when not using shader library */
391 return INDEX_NONE;
392 }
393
395 {
396 return bAtLeastOneRHIShaderCreated;
397 }
398
399 inline FRHIShader* GetShader(int32 ShaderIndex, bool bRequired = true)
400 {
401 // This is a double checked locking. This trickery arises from the fact that we're
402 // synchronizing two threads: one that takes a lock and another that doesn't.
403 // Without fences, there is a race between storing the shader pointer and accessing it
404 // on the other (lockless) thread.
405 FRHIShader* Shader = RHIShaders[ShaderIndex].load(std::memory_order_acquire);
406 if (UNLIKELY(Shader == nullptr))
407 {
408 Shader = CreateShaderOrCrash(ShaderIndex, bRequired);
409 }
410 return Shader;
411 }
412
414 virtual FSHAHash GetShaderHash(int32 ShaderIndex) = 0;
415
417 {
418 /* return invalid hash when not using shader library */
419 return FSHAHash();
420 }
421
423
424#if RHI_RAYTRACING
425
426 UE_DEPRECATED(5.6, "GetRayTracingHitGroupLibrary needs current EShaderPlatform")
428 {
430 }
431 UE_DEPRECATED(5.6, "GetRayTracingCallableShaderLibrary needs current EShaderPlatform")
433 {
435 }
436 UE_DEPRECATED(5.6, "GetRayTracingMissShaderLibrary needs current EShaderPlatform")
438 {
440 }
441
445
447 {
448 FRHIShader* Shader = GetShader(ShaderIndex); // make sure the shader is created
449 checkSlow(Shader->GetFrequency() == SF_RayHitGroup);
450 return RayTracingLibraryIndices[ShaderIndex];
451 }
452
454 {
455 FRHIShader* Shader = GetShader(ShaderIndex); // make sure the shader is created
456 checkSlow(Shader->GetFrequency() == SF_RayCallable);
457 return RayTracingLibraryIndices[ShaderIndex];
458 }
459
461 {
462 FRHIShader* Shader = GetShader(ShaderIndex); // make sure the shader is created
463 checkSlow(Shader->GetFrequency() == SF_RayMiss);
464 return RayTracingLibraryIndices[ShaderIndex];
465 }
466#endif // RHI_RAYTRACING
467
468 virtual uint32 GetSizeBytes() const = 0;
469
470protected:
473
475 {
476 SIZE_T Size = NumRHIShaders * sizeof(std::atomic<FRHIShader*>);
477#if RHI_RAYTRACING
478 Size += RayTracingLibraryIndices.GetAllocatedSize();
479#endif
480 return Size;
481 }
482
484 virtual FRHIShader* CreateRHIShaderOrCrash(int32 ShaderIndex, bool bRequired) = 0;
485
487 virtual void ReleasePreloadedShaderCode(int32 ShaderIndex) { /* no-op when not using shader library */ };
488
489 virtual bool TryRelease() { return true; }
490
492
493private:
494
496 RENDERCORE_API FRHIShader* CreateShaderOrCrash(int32 ShaderIndex, bool bRequired);
497
499 FCriticalSection RHIShadersCreationGuard;
500
501#if RHI_RAYTRACING
503#endif // RHI_RAYTRACING
504
507
509 uint32 NumRHIShaders : 31;
510
512 uint32 bAtLeastOneRHIShaderCreated : 1;
513
514 EShaderPlatform Platform;
515
517 std::atomic<int32> NumRefs;
518};
519
521{
522public:
523#if WITH_EDITORONLY_DATA
525 {
526 UE_DEPRECATED(5.6, "Use SymbolBuffer")
528
529 // Sets the symbols for this entry to the given buffer if either unset or the hash of the new buffer is "less" than the hash of the stored buffer.
530 // This is done purely for determinism's sake (we always want to store the same copy of symbols in the editoronly data for any given shader bytecode).
532
533 uint64 SymbolHash = 0u; // Used only to ensure the copy of symbols saved is stable for determinism's sake; does not need to be serialized.
535
539 FString DebugInfo;
540
546
550
552 TArray<FGenericShaderStat> ShaderStatistics;
553
555 {
556 return Ar << Entry.DebugInfo << Entry.CompilerWarnings << Entry.ShaderTypeHashes << Entry.ShaderStatistics;
557 }
558
560 // Explicitly-defaulted copy/move ctors & assignment operators are needed temporarily due to deprecation
561 // of PlatformDebugData field. These can be removed once the deprecation window for said field ends.
562 FShaderEditorOnlyDataEntry() = default;
566 FShaderEditorOnlyDataEntry& operator=(const FShaderEditorOnlyDataEntry&) = default;
568 };
569#endif // WITH_EDITORONLY_DATA
570
574
576
578#if WITH_EDITORONLY_DATA
580#endif // WITH_EDITORONLY_DATA
581
583
584 UE_DEPRECATED(5.6, "AddShaderCompilerOutput now accepts an FShaderCompileJobKey instead of DebugName")
585 inline void AddShaderCompilerOutput(const FShaderCompilerOutput& Output, const FString& DebugName = FString(), FString DebugInfo = FString()) {}
586
587 RENDERCORE_API void AddShaderCompilerOutput(const FShaderCompilerOutput& Output, const FShaderCompileJobKey& Key, FString DebugInfo = FString());
588
589 int32 FindShaderIndex(const FSHAHash& InHash) const;
590
591#if WITH_EDITORONLY_DATA
592 void AddEditorOnlyData(int32 Index, const FString& DebugName, uint64 ShaderTypeHash, FCompressedBuffer InSymbols, TConstArrayView<FShaderCompilerError> InCompilerWarnings, TArray<FGenericShaderStat>&& ShaderStatistics, const FString& DebugInfo = FString());
594
596#endif
597
598 RENDERCORE_API void ToString(FStringBuilderBase& OutString) const;
599
603
605#if WITH_EDITORONLY_DATA
606 // Optional array of editor-only data indexed in the same order as ShaderEntries (sorted by the shader hash)
607 // Empty in the cases where the editor-only data is not serialized.
609
610private:
611 // Given an existing shader entry and a new set of shader statistics determine if the shader stats match.
612 // This is to prevent non-determinism issues.
614#endif // WITH_EDITORONLY_DATA
615};
616
618{
619public:
624
625 // FShaderMapResource interface
626 RENDERCORE_API virtual FSHAHash GetShaderHash(int32 ShaderIndex) override;
627 RENDERCORE_API virtual FRHIShader* CreateRHIShaderOrCrash(int32 ShaderIndex, bool bRequired) override;
628 virtual FString GetFriendlyName() const override { return TEXT("InlineCode"); }
629 virtual uint32 GetSizeBytes() const override;
630
631 virtual uint32 GetShaderSizeBytes(int32 ShaderIndex) const override;
632
634};
635
637{
638public:
639 RENDERCORE_API virtual int32 AddIndexedPointer(const FTypeLayoutDesc& TypeDesc, void* Ptr) override;
640 RENDERCORE_API virtual void* GetIndexedPointer(const FTypeLayoutDesc& TypeDesc, uint32 i) const override;
641
642 virtual FShaderMapPointerTable* Clone() const { return new FShaderMapPointerTable(*this); }
643
644 RENDERCORE_API virtual void SaveToArchive(FArchive& Ar, const FPlatformTypeLayoutParameters& LayoutParams, const void* FrozenObject) const override;
645 RENDERCORE_API virtual bool LoadFromArchive(FArchive& Ar, const FPlatformTypeLayoutParameters& LayoutParams, void* FrozenObject) override;
646
649};
650
654{
655public:
663
664 friend inline uint32 GetTypeHash(const FShaderKey& Id)
665 {
666 return
668 HashCombine(*(uint32*)&Id.MaterialShaderMapHash, GetTypeHash(Id.Platform)),
669 HashCombine(GetTypeHash(Id.VertexFactoryType), uint32(Id.PermutationId)));
670 }
671
672 friend bool operator==(const FShaderKey& X, const FShaderKey& Y)
673 {
674 return X.MaterialShaderMapHash == Y.MaterialShaderMapHash
675 && X.ShaderPipeline == Y.ShaderPipeline
676 && X.VertexFactoryType == Y.VertexFactoryType
677 && X.PermutationId == Y.PermutationId
678 && X.Platform == Y.Platform;
679 }
680
682
688};
689
695{
696public:
697 inline FShaderId() {}
706
713
714 friend inline uint32 GetTypeHash( const FShaderId& Id )
715 {
716 return HashCombine(
717 GetTypeHash(Id.Type),
718 HashCombine(GetTypeHash(Id.VFType),
719 HashCombine(GetTypeHash(Id.ShaderPipelineName),
720 HashCombine(GetTypeHash(Id.MaterialShaderMapHash),
721 HashCombine(GetTypeHash(Id.PermutationId), GetTypeHash(Id.Platform))))));
722 }
723
724 friend bool operator==(const FShaderId& X, const FShaderId& Y)
725 {
726 return X.Type == Y.Type
727 && X.MaterialShaderMapHash == Y.MaterialShaderMapHash
728 && X.ShaderPipelineName == Y.ShaderPipelineName
729 && X.VFType == Y.VFType
730 && X.PermutationId == Y.PermutationId
731 && X.Platform == Y.Platform;
732 }
733
734 friend bool operator!=(const FShaderId& X, const FShaderId& Y)
735 {
736 return !(X == Y);
737 }
738};
739
740class FMaterial;
741
746{
747public:
749 {
751
752 LAYOUT_FIELD(uint16, BufferIndex);
753 LAYOUT_FIELD(uint16, BaseIndex);
754 LAYOUT_FIELD(uint16, ByteOffset);
756 };
757
765
773
780
782public:
783 static constexpr uint16 kInvalidBufferIndex = 0xFFFF;
784
787
793
794 // Hash of the shader parameter structure when doing the binding.
796
797 // Buffer index of FShaderParametersMetadata::kRootUniformBufferBindingName
799
800}; // FShaderParameterBindings
801
802inline int16 GetParameterIndex(const FShaderParameterBindings::FResourceParameter& Parameter) { return Parameter.BaseIndex; }
803inline int16 GetParameterIndex(const FShaderParameterBindings::FBindlessResourceParameter& Parameter) { return Parameter.GlobalConstantOffset; }
804inline int16 GetParameterIndex(const FShaderParameterBindings::FParameterStructReference& Parameter) { return Parameter.BufferIndex; }
805
807{
808 Precached, //< Permutation should be precached because it can be used at runtime
809 NotPrecached, //< Permutation doesn't have to be precached (debug feature only for example)
810 NotUsed, //< Permutation is not used with current cvar/configuration/feature level
811};
812
817
818namespace Freeze
819{
822}
823
826
829{
830 friend class FShaderType;
832public:
839
845
850
852
855
858
860 static bool ShouldCompilePermutation(const FShaderPermutationParameters&) { return true; }
861
864
867
871
873 static ERayTracingPayloadType GetRayTracingPayloadType(const int32 PermutationId) { return static_cast<ERayTracingPayloadType>(0); }
874
876 RENDERCORE_API const FSHAHash& GetHash() const;
877
879
881
883 uint32 GetSortKey() const { return SortKey; }
884
886
887 // Accessors.
888 inline FShaderType* GetType(const FShaderMapPointerTable& InPointerTable) const { return Type.Get(InPointerTable.ShaderTypes); }
889 inline FShaderType* GetType(const FPointerTableBase* InPointerTable) const { return Type.Get(InPointerTable); }
892 inline FShaderType* GetTypeUnfrozen() const { return Type.GetUnfrozen(); }
893 inline int32 GetResourceIndex() const { checkSlow(ResourceIndex != INDEX_NONE); return ResourceIndex; }
894 inline EShaderPlatform GetShaderPlatform() const { return Target.GetPlatform(); }
895 inline EShaderFrequency GetFrequency() const { return Target.GetFrequency(); }
896 inline const FShaderTarget GetTarget() const { return Target; }
897 inline bool IsFrozen() const { return Type.IsFrozen(); }
898
899#if WITH_EDITORONLY_DATA
900 inline uint32 GetNumInstructions() const { return NumInstructions; }
901 inline uint32 GetNumTextureSamplers() const { return NumTextureSamplers; }
902 inline uint32 GetCodeSize() const { return CodeSize; }
903 inline void SetNumInstructions(uint32 Value) { NumInstructions = Value; }
904#else
905 inline uint32 GetNumInstructions() const { return 0u; }
906 inline uint32 GetNumTextureSamplers() const { return 0u; }
907 inline uint32 GetCodeSize() const { return 0u; }
909#endif
910
912 template<typename UniformBufferStructType>
914 {
915 const FShaderUniformBufferParameter& FoundParameter = GetUniformBufferParameter(UniformBufferStructType::FTypeInfo::GetStructMetadata());
917 }
918
921 {
922 const FHashedName SearchName = SearchStruct->GetShaderVariableHashedName();
923
925 }
926
929 {
930 int32 FoundIndex = INDEX_NONE;
933 {
935 {
936 FoundIndex = StructIndex;
937 break;
938 }
939 }
940
941 if (FoundIndex != INDEX_NONE)
942 {
944 return FoundParameter;
945 }
946 else
947 {
948 // This can happen if the uniform buffer was not bound
949 // There's no good way to distinguish not being bound due to temporary debugging / compiler optimizations or an actual code bug,
950 // Hence failing silently instead of an error message
952 return UnboundParameter;
953 }
954 }
955
957
959
960#if WITH_EDITOR
962#endif // WITH_EDITOR
963
966 {
967 return nullptr;
968 }
969
970private:
971 RENDERCORE_API void BuildParameterMapInfo(const TMap<FString, FParameterAllocation>& ParameterMap);
972
973public:
976
977protected:
980
986
989
992
993private:
995
997
1000
1002 LAYOUT_FIELD(int32, ResourceIndex);
1003
1005 LAYOUT_FIELD_EDITORONLY(uint32, NumInstructions);
1006
1008 LAYOUT_FIELD(uint32, SortKey);
1009
1011 LAYOUT_FIELD_EDITORONLY(uint32, NumTextureSamplers);
1012
1015};
1016
1018
1019template<typename ShaderType, typename PointerTableType>
1021{
1022public:
1023 TShaderRefBase() : ShaderContent(nullptr), ShaderMap(nullptr) {}
1024 TShaderRefBase(ShaderType* InShader, const FShaderMapBase& InShaderMap) : ShaderContent(InShader), ShaderMap(&InShaderMap) { checkSlow(InShader); }
1026
1027 template<typename OtherShaderType, typename OtherPointerTableType>
1029
1031
1032 template<typename OtherShaderType, typename OtherPointerTableType>
1034 {
1035 ShaderContent = Rhs.GetShader();
1036 ShaderMap = Rhs.GetShaderMap();
1037 return *this;
1038 }
1039
1040 template<typename OtherShaderType, typename OtherPointerTableType>
1042 {
1043 return TShaderRefBase<ShaderType, PointerTableType>(static_cast<ShaderType*>(Rhs.GetShader()), Rhs.GetShaderMap());
1044 }
1045
1046 template<typename OtherShaderType, typename OtherPointerTableType>
1048 {
1049 return TShaderRefBase<ShaderType, PointerTableType>(reinterpret_cast<ShaderType*>(Rhs.GetShader()), Rhs.GetShaderMap());
1050 }
1051
1052 inline bool IsValid() const { return ShaderContent != nullptr; }
1053 inline bool IsNull() const { return ShaderContent == nullptr; }
1054
1055 inline void Reset() { ShaderContent = nullptr; ShaderMap = nullptr; }
1056
1057 inline ShaderType* GetShader() const { return ShaderContent; }
1058 inline const FShaderMapBase* GetShaderMap() const { return ShaderMap; }
1059 inline const FShaderMapBase& GetShaderMapChecked() const { check(ShaderMap); return *ShaderMap; }
1060 inline FShaderType* GetType() const { return ShaderContent->GetType(GetPointerTable()); }
1061 inline FVertexFactoryType* GetVertexFactoryType() const { return ShaderContent->GetVertexFactoryType(GetPointerTable()); }
1062 inline FShaderMapResource& GetResourceChecked() const { FShaderMapResource* Resource = GetResource(); check(Resource); return *Resource; }
1065
1066 inline ShaderType* operator->() const { return ShaderContent; }
1067
1068 inline FRHIShader* GetRHIShaderBase(EShaderFrequency Frequency, bool bRequired = true) const
1069 {
1070 FRHIShader* RHIShader = nullptr;
1071 if(ShaderContent)
1072 {
1073 checkSlow(ShaderContent->GetFrequency() == Frequency);
1074 RHIShader = GetResourceChecked().GetShader(ShaderContent->GetResourceIndex(), bRequired);
1075 if (RHIShader == nullptr)
1076 {
1077 UE_LOG(LogShaders, Log, TEXT("Failed to create shader for type %s with resource index %d."), GetType()->GetName(), ShaderContent->GetResourceIndex());
1078 return nullptr;
1079 }
1080 checkSlow(RHIShader->GetFrequency() == Frequency);
1081 }
1082 return RHIShader;
1083 }
1084
1085 inline FRHIGraphicsShader* GetGraphicsShader(bool bRequired = true) const
1086 {
1087 FRHIGraphicsShader* RHIShader = nullptr;
1088 if(ShaderContent)
1089 {
1090 checkSlow(IsValidGraphicsFrequency(ShaderContent->GetFrequency()));
1091 RHIShader = static_cast<FRHIGraphicsShader*>(GetResourceChecked().GetShader(ShaderContent->GetResourceIndex(), bRequired));
1092 if (RHIShader == nullptr)
1093 {
1094 UE_LOG(LogShaders, Log, TEXT("Failed to create shader for type %s with resource index %d."), GetType()->GetName(), ShaderContent->GetResourceIndex());
1095 return nullptr;
1096 }
1098 }
1099 return RHIShader;
1100 }
1101
1103 inline FRHIVertexShader* GetVertexShader(bool bRequired = true) const
1104 {
1105 return static_cast<FRHIVertexShader*>(GetRHIShaderBase(SF_Vertex, bRequired));
1106 }
1109 {
1110 return static_cast<FRHIMeshShader*>(GetRHIShaderBase(SF_Mesh));
1111 }
1118 inline FRHIPixelShader* GetPixelShader(bool bRequired = true) const
1119 {
1120 return static_cast<FRHIPixelShader*>(GetRHIShaderBase(SF_Pixel, bRequired));
1121 }
1124 {
1125 return static_cast<FRHIGeometryShader*>(GetRHIShaderBase(SF_Geometry));
1126 }
1129 {
1130 return static_cast<FRHIComputeShader*>(GetRHIShaderBase(SF_Compute));
1131 }
1134 {
1135 FRHIWorkGraphShader* RHIShader = nullptr;
1136 if (ShaderContent)
1137 {
1138 const EShaderFrequency Frequency = ShaderContent->GetFrequency();
1140 RHIShader = static_cast<FRHIWorkGraphShader*>(GetRHIShaderBase(Frequency));
1141 }
1142 return RHIShader;
1143 }
1144
1145#if RHI_RAYTRACING
1147 {
1148 FRHIRayTracingShader* RHIShader = nullptr;
1149 if(ShaderContent)
1150 {
1151 const EShaderFrequency Frequency = ShaderContent->GetFrequency();
1153 || Frequency == SF_RayMiss
1156 RHIShader = static_cast<FRHIRayTracingShader*>(GetResourceChecked().GetShader(ShaderContent->GetResourceIndex()));
1157 checkSlow(RHIShader->GetFrequency() == Frequency);
1158 }
1159 return RHIShader;
1160 }
1161
1162 UE_DEPRECATED(5.1, "GetRayTracingMaterialLibraryIndex is deprecated. Use GetRayTracingHitGroupLibraryIndex instead.")
1164 {
1166 }
1167
1169 {
1170 checkSlow(ShaderContent);
1171 checkSlow(ShaderContent->GetFrequency() == SF_RayHitGroup);
1172 return GetResourceChecked().GetRayTracingHitGroupLibraryIndex(ShaderContent->GetResourceIndex());
1173 }
1174
1176 {
1177 checkSlow(ShaderContent);
1178 checkSlow(ShaderContent->GetFrequency() == SF_RayCallable);
1179 return GetResourceChecked().GetRayTracingCallableShaderLibraryIndex(ShaderContent->GetResourceIndex());
1180 }
1181
1183 {
1184 checkSlow(ShaderContent);
1185 checkSlow(ShaderContent->GetFrequency() == SF_RayMiss);
1186 return GetResourceChecked().GetRayTracingMissShaderLibraryIndex(ShaderContent->GetResourceIndex());
1187 }
1188#endif // RHI_RAYTRACING
1189
1190private:
1192 : ShaderContent(InShader), ShaderMap(InShaderMap)
1193 {
1195 }
1196
1197 ShaderType* ShaderContent;
1198 const FShaderMapBase* ShaderMap;
1199
1200 template<typename ShaderType1>
1202 {
1203 if (Lhs.GetShader() == Rhs.GetShader())
1204 {
1205 check(Lhs.GetShaderMap() == Rhs.GetShaderMap());
1206 return true;
1207 }
1208 return false;
1209 }
1210
1211 template<typename ShaderType1>
1213 {
1214 return !operator==(Lhs, Rhs);
1215 }
1216
1217};
1218
1219template<typename ShaderType>
1221
1222#define SHADER_TYPE_LIST \
1223 SHADER_TYPE_ENTRY(Global), \
1224 SHADER_TYPE_ENTRY(Material), \
1225 SHADER_TYPE_ENTRY(MeshMaterial), \
1226 SHADER_TYPE_ENTRY(Niagara), \
1227 SHADER_TYPE_ENTRY(OCIO), \
1228 SHADER_TYPE_ENTRY(ComputeKernel), \
1229 SHADER_TYPE_ENTRY(NNERuntimeIREE),
1230
1238{
1239public:
1240#define SHADER_TYPE_ENTRY(Name) Name
1242 {
1245 };
1246#undef SHADER_TYPE_ENTRY
1247
1252 {
1253 public:
1254 virtual ~FParameters(){}
1255 };
1256
1257 typedef class FShader* (*ConstructSerializedType)();
1258 typedef FShader* (*ConstructCompiledType)(const FShader::CompiledShaderInitializerType& Initializer);
1262 typedef const FShaderBindingLayout*(*GetShaderBindingLayoutType)(const FShaderPermutationParameters&);
1263#if WITH_EDITOR
1267 typedef void (*GetPermutationIdStringType)(int32 PermutationId, FString&, bool);
1268#endif // WITH_EDITOR
1269
1272
1276
1279
1281
1284
1287
1292 const TCHAR* InName,
1293 const TCHAR* InSourceFilename,
1294 const TCHAR* InFunctionName,
1296 int32 TotalPermutationCount,
1303#if WITH_EDITOR
1307#endif // WITH_EDITOR
1310#if WITH_EDITOR
1312#endif
1313
1314 );
1315
1316 RENDERCORE_API virtual ~FShaderType();
1317
1321
1325
1326#if WITH_EDITOR
1327 RENDERCORE_API void ModifyCompilationEnvironment(const FShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment) const;
1328
1335 RENDERCORE_API bool ValidateCompiledResult(EShaderPlatform Platform, const FShaderParameterMap& ParameterMap, TArray<FString>& OutError) const;
1336
1338 RENDERCORE_API EShaderCompileJobPriority GetOverrideJobPriority() const;
1339
1345 RENDERCORE_API FString GetPermutationIdString(int32 PermutationId, bool bFullNames) const;
1346#endif // WITH_EDITOR
1347
1349
1351 RENDERCORE_API const FSHAHash& GetSourceHash(EShaderPlatform ShaderPlatform) const;
1352
1355
1358 {
1359 return Ref ? GetTypeHash(Ref->HashedName) : 0u;
1360 }
1361
1362 // Dynamic casts.
1364 {
1365 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Global) ? reinterpret_cast<FGlobalShaderType*>(this) : nullptr;
1366 }
1368 {
1369 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Global) ? reinterpret_cast<const FGlobalShaderType*>(this) : nullptr;
1370 }
1372 {
1373 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Material) ? reinterpret_cast<FMaterialShaderType*>(this) : nullptr;
1374 }
1376 {
1377 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Material) ? reinterpret_cast<const FMaterialShaderType*>(this) : nullptr;
1378 }
1380 {
1381 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::MeshMaterial) ? reinterpret_cast<FMeshMaterialShaderType*>(this) : nullptr;
1382 }
1384 {
1385 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::MeshMaterial) ? reinterpret_cast<const FMeshMaterialShaderType*>(this) : nullptr;
1386 }
1388 {
1389 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Niagara) ? reinterpret_cast<const FNiagaraShaderType*>(this) : nullptr;
1390 }
1392 {
1393 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Niagara) ? reinterpret_cast<FNiagaraShaderType*>(this) : nullptr;
1394 }
1396 {
1397 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::OCIO) ? reinterpret_cast<const FOpenColorIOShaderType*>(this) : nullptr;
1398 }
1400 {
1401 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::OCIO) ? reinterpret_cast<FOpenColorIOShaderType*>(this) : nullptr;
1402 }
1404 {
1405 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::ComputeKernel) ? reinterpret_cast<const FComputeKernelShaderType*>(this) : nullptr;
1406 }
1408 {
1409 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::ComputeKernel) ? reinterpret_cast<FComputeKernelShaderType*>(this) : nullptr;
1410 }
1412 {
1413 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::NNERuntimeIREE) ? reinterpret_cast<const FNNERuntimeIREEShaderType*>(this) : nullptr;
1414 }
1416 {
1417 return (ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::NNERuntimeIREE) ? reinterpret_cast<FNNERuntimeIREEShaderType*>(this) : nullptr;
1418 }
1419
1421 {
1422 checkf(ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Global, TEXT("ShaderType %s is not Global"), GetName());
1423 return reinterpret_cast<const FGlobalShaderType*>(this);
1424 }
1425
1427 {
1428 checkf(ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Material, TEXT("ShaderType %s is not Material"), GetName());
1429 return reinterpret_cast<const FMaterialShaderType*>(this);
1430 }
1431
1433 {
1434 checkf(ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::MeshMaterial, TEXT("ShaderType %s is not MeshMaterial"), GetName());
1435 return reinterpret_cast<const FMeshMaterialShaderType*>(this);
1436 }
1437
1439 {
1440 checkf(ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::Niagara, TEXT("ShaderType %s is not Niagara"), GetName());
1441 return reinterpret_cast<const FNiagaraShaderType*>(this);
1442 }
1443
1445 {
1446 checkf(ShaderTypeForDynamicCast == EShaderTypeForDynamicCast::OCIO, TEXT("ShaderType %s is not OCIO"), GetName());
1447 return reinterpret_cast<const FOpenColorIOShaderType*>(this);
1448 }
1449
1451 {
1452 return ShaderTypeForDynamicCast;
1453 }
1454
1455 // Accessors.
1456 inline const FTypeLayoutDesc& GetLayout() const
1457 {
1458 return *TypeLayout;
1459 }
1461 {
1462 return (EShaderFrequency)Frequency;
1463 }
1464 inline const TCHAR* GetName() const
1465 {
1466 return Name;
1467 }
1468 inline const FName& GetFName() const
1469 {
1470 return TypeName;
1471 }
1472 inline const FHashedName& GetHashedName() const
1473 {
1474 return HashedName;
1475 }
1476 inline const TCHAR* GetShaderFilename() const
1477 {
1478 return SourceFilename;
1479 }
1481 {
1482 return HashedSourceFilename;
1483 }
1484 inline const TCHAR* GetFunctionName() const
1485 {
1486 return FunctionName;
1487 }
1488 inline uint32 GetTypeSize() const
1489 {
1490 return TypeSize;
1491 }
1492
1493 inline int32 GetNumShaders() const
1494 {
1495 // TODO count this
1496 return 0;
1497 }
1498
1500 {
1501 return TotalPermutationCount;
1502 }
1503
1506 {
1507 return RootParametersMetadata;
1508 }
1509
1510#if WITH_EDITOR
1512 {
1513 return ReferencedUniformBuffers;
1514 }
1515
1518
1520
1522#endif // WITH_EDITOR
1523
1525
1526private:
1527 EShaderTypeForDynamicCast ShaderTypeForDynamicCast;
1528 const FTypeLayoutDesc* TypeLayout;
1529 const TCHAR* Name;
1530 FName TypeName;
1531 FHashedName HashedName;
1532 FHashedName HashedSourceFilename;
1533 const TCHAR* SourceFilename;
1534 const TCHAR* FunctionName;
1536 uint32 TypeSize;
1537 int32 TotalPermutationCount;
1538
1539 ConstructSerializedType ConstructSerializedRef;
1540 ConstructCompiledType ConstructCompiledRef;
1541 ShouldCompilePermutationType ShouldCompilePermutationRef;
1542 ShouldPrecachePermutationType ShouldPrecachePermutationRef;
1543 GetRayTracingPayloadTypeType GetRayTracingPayloadTypeRef;
1544 GetShaderBindingLayoutType GetShaderBindingLayoutTypeRef;
1545#if WITH_EDITOR
1550#endif
1551 const FShaderParametersMetadata* const RootParametersMetadata;
1552
1553 TLinkedList<FShaderType*> GlobalListLink;
1554
1556
1557#if WITH_EDITOR
1558protected:
1564 TSet<const FShaderParametersMetadata*> ReferencedUniformBuffers;
1565#endif // WITH_EDITOR
1566};
1567
1569{
1570#define SHADER_TYPE_ENTRY(Name) TEXT(#Name)
1571 static const TCHAR* TypeStrings[] =
1572 {
1574 };
1575#undef SHADER_TYPE_ENTRY
1576 checkf(ShaderType < FShaderType::EShaderTypeForDynamicCast::NumShaderTypes, TEXT("Invalid shader type"));
1577 static_assert((sizeof(TypeStrings) / sizeof(TCHAR*)) == (int)FShaderType::EShaderTypeForDynamicCast::NumShaderTypes);
1578 return TypeStrings[static_cast<uint32>(ShaderType)];
1579}
1580
1589{
1590public:
1592 : LazyShaderTypeAccessor(LazyShaderTypeAccessor)
1593 {
1594 checkf(!AreShaderTypesInitialized(), TEXT("Shader type was loaded too late, use ELoadingPhase::PostConfigInit on your module to cause it to load earlier. This shader will not be compiled or function. The module and shader will appear in the callstack of this assert."));
1595 GetInstances().Add(this);
1596 }
1597
1599
1600 // Actually register all the types and clear the array
1601 static RENDERCORE_API void CommitAll();
1603
1604private:
1605 static bool bShaderTypesInitialized;
1606 TFunctionRef<FShaderType& ()> LazyShaderTypeAccessor;
1607};
1608
1636
1637#if WITH_EDITOR
1638 #define SHADER_DECLARE_EDITOR_VTABLE(ShaderClass) \
1639 static void ModifyCompilationEnvironmentImpl(const FShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment) \
1640 { \
1641 const typename ShaderClass::FPermutationDomain PermutationVector(Parameters.PermutationId); \
1642 PermutationVector.ModifyCompilationEnvironment(OutEnvironment); \
1643 ShaderClass::ModifyCompilationEnvironment(static_cast<const typename ShaderClass::FPermutationParameters&>(Parameters), OutEnvironment); \
1644 } \
1645 static void GetPermutationIdStringImpl(int32 PermutationId, FString& OutString, bool bFullNames) \
1646 { \
1647 const typename ShaderClass::FPermutationDomain PermutationVector(PermutationId); \
1648 UE::ShaderPermutationUtils::FormatPermutationDomain(PermutationVector, OutString, bFullNames, nullptr); \
1649 }
1650#else
1651 #define SHADER_DECLARE_EDITOR_VTABLE(ShaderClass)
1652#endif // WITH_EDITOR
1653
1654#define SHADER_DECLARE_VTABLE(ShaderClass) \
1655 static FShader* ConstructSerializedInstance() { return new ShaderClass(); } \
1656 static FShader* ConstructCompiledInstance(const typename FShader::CompiledShaderInitializerType& Initializer) \
1657 { return new ShaderClass(static_cast<const typename ShaderMetaType::CompiledShaderInitializerType&>(Initializer)); }\
1658 static bool ShouldCompilePermutationImpl(const FShaderPermutationParameters& Parameters) \
1659 { return ShaderClass::ShouldCompilePermutation(static_cast<const typename ShaderClass::FPermutationParameters&>(Parameters)); } \
1660 static EShaderPermutationPrecacheRequest ShouldPrecachePermutationImpl(const FShaderPermutationParameters& Parameters) \
1661 { return ShaderClass::ShouldPrecachePermutation(static_cast<const typename ShaderClass::FPermutationParameters&>(Parameters)); } \
1662 SHADER_DECLARE_EDITOR_VTABLE(ShaderClass)
1663
1664
1665#define INTERNAL_DECLARE_SHADER_TYPE_COMMON(ShaderClass,ShaderMetaTypeShortcut,RequiredAPI) \
1666 public: \
1667 using ShaderMetaType = F##ShaderMetaTypeShortcut##ShaderType; \
1668 using ShaderMapType = F##ShaderMetaTypeShortcut##ShaderMap; \
1669 \
1670 static RequiredAPI ShaderMetaType& GetStaticType(); \
1671 private: \
1672 static FShaderTypeRegistration ShaderTypeRegistration; \
1673 public: \
1674 \
1675 SHADER_DECLARE_VTABLE(ShaderClass)
1676
1683#define DECLARE_EXPORTED_SHADER_TYPE(ShaderClass,ShaderMetaTypeShortcut,RequiredAPI, ...) \
1684 INTERNAL_DECLARE_SHADER_TYPE_COMMON(ShaderClass, ShaderMetaTypeShortcut, RequiredAPI); \
1685 DECLARE_EXPORTED_TYPE_LAYOUT(ShaderClass, RequiredAPI, NonVirtual); \
1686 public:
1687
1688#define DECLARE_SHADER_TYPE(ShaderClass,ShaderMetaTypeShortcut,...) \
1689 DECLARE_EXPORTED_SHADER_TYPE(ShaderClass,ShaderMetaTypeShortcut,, ##__VA_ARGS__)
1690
1691#define DECLARE_SHADER_TYPE_EXPLICIT_BASES(ShaderClass,ShaderMetaTypeShortcut,...) \
1692 INTERNAL_DECLARE_SHADER_TYPE_COMMON(ShaderClass, ShaderMetaTypeShortcut,); \
1693 DECLARE_EXPORTED_TYPE_LAYOUT_EXPLICIT_BASES(ShaderClass,, NonVirtual, __VA_ARGS__); \
1694 public:
1695
1696#if WITH_EDITOR
1697
1698#define SHADER_TYPE_EDITOR_VTABLE(ShaderClass) \
1699 , ShaderClass::ModifyCompilationEnvironmentImpl \
1700 , ShaderClass::ValidateCompiledResult \
1701 , ShaderClass::GetOverrideJobPriority
1702
1703#define SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass) \
1704 , ShaderClass::GetPermutationIdStringImpl
1705
1706#else
1707
1708#define SHADER_TYPE_EDITOR_VTABLE(ShaderClass)
1709#define SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass)
1710
1711#endif
1712
1713#define SHADER_TYPE_VTABLE(ShaderClass) \
1714 ShaderClass::ConstructSerializedInstance, \
1715 ShaderClass::ConstructCompiledInstance, \
1716 ShaderClass::ShouldCompilePermutationImpl, \
1717 ShaderClass::ShouldPrecachePermutationImpl, \
1718 ShaderClass::GetRayTracingPayloadType, \
1719 ShaderClass::GetShaderBindingLayout \
1720 SHADER_TYPE_EDITOR_VTABLE(ShaderClass)
1721
1722#if !UE_BUILD_DOCS
1724#define IMPLEMENT_SHADER_TYPE(TemplatePrefix,ShaderClass,SourceFilename,FunctionName,Frequency) \
1725 IMPLEMENT_UNREGISTERED_TEMPLATE_TYPE_LAYOUT(TemplatePrefix, ShaderClass); \
1726 TemplatePrefix \
1727 ShaderClass::ShaderMetaType& ShaderClass::GetStaticType() \
1728 { \
1729 static ShaderClass::ShaderMetaType StaticType( \
1730 ShaderClass::StaticGetTypeLayout(), \
1731 TEXT(#ShaderClass), \
1732 SourceFilename, \
1733 FunctionName, \
1734 Frequency, \
1735 ShaderClass::FPermutationDomain::PermutationCount, \
1736 SHADER_TYPE_VTABLE(ShaderClass), \
1737 sizeof(ShaderClass), \
1738 ShaderClass::GetRootParametersMetadata() \
1739 SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass) \
1740 ); \
1741 return StaticType; \
1742 } \
1743 TemplatePrefix FShaderTypeRegistration ShaderClass::ShaderTypeRegistration{TFunctionRef<::FShaderType&()>{ShaderClass::GetStaticType}};
1744
1746#define IMPLEMENT_SHADER_TYPE_WITH_DEBUG_NAME(TemplatePrefix,ShaderClass,SourceFilename,FunctionName,Frequency) \
1747 IMPLEMENT_UNREGISTERED_TEMPLATE_TYPE_LAYOUT(TemplatePrefix, ShaderClass); \
1748 TemplatePrefix \
1749 typename ShaderClass::ShaderMetaType& ShaderClass::GetStaticType() \
1750 { \
1751 static typename ShaderClass::ShaderMetaType StaticType( \
1752 ShaderClass::StaticGetTypeLayout(), \
1753 ShaderClass::GetDebugName(), \
1754 SourceFilename, \
1755 FunctionName, \
1756 Frequency, \
1757 ShaderClass::FPermutationDomain::PermutationCount, \
1758 SHADER_TYPE_VTABLE(ShaderClass), \
1759 sizeof(ShaderClass), \
1760 ShaderClass::GetRootParametersMetadata() \
1761 SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass) \
1762 ); \
1763 return StaticType; \
1764 } \
1765 TemplatePrefix FShaderTypeRegistration ShaderClass::ShaderTypeRegistration{TFunctionRef<::FShaderType&()>{ShaderClass::GetStaticType}};
1766
1768#define IMPLEMENT_SHADER_TYPE2_WITH_TEMPLATE_PREFIX(TemplatePrefix,ShaderClass,Frequency) \
1769 IMPLEMENT_UNREGISTERED_TEMPLATE_TYPE_LAYOUT(TemplatePrefix, ShaderClass); \
1770 TemplatePrefix \
1771 ShaderClass::ShaderMetaType& ShaderClass::GetStaticType() \
1772 { \
1773 static ShaderClass::ShaderMetaType StaticType( \
1774 ShaderClass::StaticGetTypeLayout(), \
1775 TEXT(#ShaderClass), \
1776 ShaderClass::GetSourceFilename(), \
1777 ShaderClass::GetFunctionName(), \
1778 Frequency, \
1779 ShaderClass::FPermutationDomain::PermutationCount, \
1780 SHADER_TYPE_VTABLE(ShaderClass), \
1781 sizeof(ShaderClass), \
1782 ShaderClass::GetRootParametersMetadata() \
1783 SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass) \
1784 ); \
1785 return StaticType; \
1786 } \
1787 TemplatePrefix FShaderTypeRegistration ShaderClass::ShaderTypeRegistration{TFunctionRef<::FShaderType&()>{ShaderClass::GetStaticType}};
1788
1789#define IMPLEMENT_SHADER_TYPE2(ShaderClass,Frequency) \
1790 IMPLEMENT_SHADER_TYPE2_WITH_TEMPLATE_PREFIX(template<>, ShaderClass, Frequency)
1791
1793#define IMPLEMENT_SHADER_TYPE3(ShaderClass,Frequency) \
1794 IMPLEMENT_UNREGISTERED_TEMPLATE_TYPE_LAYOUT(,ShaderClass); \
1795 ShaderClass::ShaderMetaType& ShaderClass::GetStaticType() \
1796 { \
1797 static ShaderClass::ShaderMetaType StaticType( \
1798 ShaderClass::StaticGetTypeLayout(), \
1799 TEXT(#ShaderClass), \
1800 ShaderClass::GetSourceFilename(), \
1801 ShaderClass::GetFunctionName(), \
1802 Frequency, \
1803 ShaderClass::FPermutationDomain::PermutationCount, \
1804 SHADER_TYPE_VTABLE(ShaderClass), \
1805 sizeof(ShaderClass), \
1806 ShaderClass::GetRootParametersMetadata() \
1807 SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass) \
1808 ); \
1809 return StaticType; \
1810 } \
1811 FShaderTypeRegistration ShaderClass::ShaderTypeRegistration{TFunctionRef<::FShaderType&()>{ShaderClass::GetStaticType}};
1812#endif // !UE_BUILD_DOCS
1813
1814#define IMPLEMENT_SHADER_TYPE4_WITH_TEMPLATE_PREFIX(TemplatePrefix,RequiredAPI,ShaderClass,Frequency) \
1815 IMPLEMENT_UNREGISTERED_TEMPLATE_TYPE_LAYOUT(TemplatePrefix, ShaderClass); \
1816 TemplatePrefix RequiredAPI \
1817 ShaderClass::ShaderMetaType& ShaderClass::GetStaticType() \
1818 { \
1819 static ShaderClass::ShaderMetaType StaticType( \
1820 ShaderClass::StaticGetTypeLayout(), \
1821 TEXT(#ShaderClass), \
1822 ShaderClass::GetSourceFilename(), \
1823 ShaderClass::GetFunctionName(), \
1824 Frequency, \
1825 ShaderClass::FPermutationDomain::PermutationCount, \
1826 SHADER_TYPE_VTABLE(ShaderClass), \
1827 sizeof(ShaderClass), \
1828 ShaderClass::GetRootParametersMetadata() \
1829 SHADER_TYPE_EDITOR_PERMUTATION_METADATA(ShaderClass) \
1830 ); \
1831 return StaticType; \
1832 } \
1833 TemplatePrefix FShaderTypeRegistration ShaderClass::ShaderTypeRegistration{TFunctionRef<::FShaderType&()>{ShaderClass::GetStaticType}};
1834
1835#if WITH_EDITOR
1836
1837#define IMPLEMENT_SHADER_TYPE_CONSTRUCTOR(ShaderClass, InShaderTypeForDynamicCast, InShaderClassUserFriendlyName) \
1838 ShaderClass( \
1839 FTypeLayoutDesc& InTypeLayout, \
1840 const TCHAR* InName, \
1841 const TCHAR* InSourceFilename, \
1842 const TCHAR* InFunctionName, \
1843 uint32 InFrequency, \
1844 int32 InTotalPermutationCount, \
1845 ConstructSerializedType InConstructSerializedRef, \
1846 ConstructCompiledType InConstructCompiledRef, \
1847 ShouldCompilePermutationType InShouldCompilePermutationRef, \
1848 ShouldPrecachePermutationType InShouldPrecachePermutationRef, \
1849 GetRayTracingPayloadTypeType InGetRayTracingPayloadTypeRef, \
1850 GetShaderBindingLayoutType InGetShaderBindingLayoutTypeRef, \
1851 ModifyCompilationEnvironmentType InModifyCompilationEnvironmentRef, \
1852 ValidateCompiledResultType InValidateCompiledResultRef, \
1853 GetOverrideJobPriorityType InGetOverrideJobPriorityRef, \
1854 uint32 InTypeSize, \
1855 const FShaderParametersMetadata* InRootParametersMetadata = nullptr, \
1856 GetPermutationIdStringType InGetPermutationIdStringRef = nullptr \
1857 ): \
1858 FShaderType( \
1859 InShaderTypeForDynamicCast, \
1860 InTypeLayout, \
1861 InName, \
1862 InSourceFilename, \
1863 InFunctionName, \
1864 InFrequency, \
1865 InTotalPermutationCount, \
1866 InConstructSerializedRef, \
1867 InConstructCompiledRef, \
1868 InShouldCompilePermutationRef, \
1869 InShouldPrecachePermutationRef, \
1870 InGetRayTracingPayloadTypeRef, \
1871 InGetShaderBindingLayoutTypeRef, \
1872 InModifyCompilationEnvironmentRef, \
1873 InValidateCompiledResultRef, \
1874 InGetOverrideJobPriorityRef, \
1875 InTypeSize, \
1876 InRootParametersMetadata, \
1877 InGetPermutationIdStringRef \
1878 ) \
1879 { \
1880 checkf(FPaths::GetExtension(InSourceFilename) == TEXT("usf"), \
1881 TEXT("Incorrect virtual shader path extension for %s '%s': Only .usf files should be compiled."), \
1882 InShaderClassUserFriendlyName, InSourceFilename); \
1883 }
1884
1885#else
1886
1887#define IMPLEMENT_SHADER_TYPE_CONSTRUCTOR(ShaderClass, InShaderTypeForDynamicCast, InShaderClassUserFriendlyName) \
1888 ShaderClass( \
1889 FTypeLayoutDesc& InTypeLayout, \
1890 const TCHAR* InName, \
1891 const TCHAR* InSourceFilename, \
1892 const TCHAR* InFunctionName, \
1893 uint32 InFrequency, \
1894 int32 InTotalPermutationCount, \
1895 ConstructSerializedType InConstructSerializedRef, \
1896 ConstructCompiledType InConstructCompiledRef, \
1897 ShouldCompilePermutationType InShouldCompilePermutationRef, \
1898 ShouldPrecachePermutationType InShouldPrecachePermutationRef, \
1899 GetRayTracingPayloadTypeType InGetRayTracingPayloadTypeRef, \
1900 GetShaderBindingLayoutType InGetShaderBindingLayoutTypeRef, \
1901 uint32 InTypeSize, \
1902 const FShaderParametersMetadata* InRootParametersMetadata = nullptr \
1903 ): \
1904 FShaderType( \
1905 InShaderTypeForDynamicCast, \
1906 InTypeLayout, \
1907 InName, \
1908 InSourceFilename, \
1909 InFunctionName, \
1910 InFrequency, \
1911 InTotalPermutationCount, \
1912 InConstructSerializedRef, \
1913 InConstructCompiledRef, \
1914 InShouldCompilePermutationRef, \
1915 InShouldPrecachePermutationRef, \
1916 InGetRayTracingPayloadTypeRef, \
1917 InGetShaderBindingLayoutTypeRef, \
1918 InTypeSize, \
1919 InRootParametersMetadata \
1920 ) \
1921 { \
1922 checkf(FPaths::GetExtension(InSourceFilename) == TEXT("usf"), \
1923 TEXT("Incorrect virtual shader path extension for %s '%s': Only .usf files should be compiled."), \
1924 InShaderClassUserFriendlyName, InSourceFilename); \
1925 }
1926
1927#endif // WITH_EDITOR
1928
1929// Binding of a set of shader stages in a single pipeline
1931{
1932public:
1933 // Set bShouldOptimizeUnusedOutputs to true if we want unique FShaders for each shader pipeline
1934 // Set bShouldOptimizeUnusedOutputs to false if the FShaders will point to the individual shaders in the map
1936 const TCHAR* InName,
1940 bool bInIsMeshPipeline,
1943
1944 inline bool HasMeshShader() const { return AllStages[SF_Mesh] != nullptr; }
1945 inline bool HasGeometry() const { return AllStages[SF_Geometry] != nullptr; }
1946 inline bool HasPixelShader() const { return AllStages[SF_Pixel] != nullptr; }
1947
1949 {
1951 return AllStages[Frequency];
1952 }
1953
1954 inline FName GetFName() const { return TypeName; }
1955 inline TCHAR const* GetName() const { return Name; }
1956 inline const FHashedName& GetHashedName() const { return HashedName; }
1958
1959 // Returns an array of valid stages, sorted from PS->GS->DS->HS->VS, no gaps if missing stages
1960 inline const TArray<const FShaderType*>& GetStages() const { return Stages; }
1961
1963
1965
1969
1971 static RENDERCORE_API void Initialize();
1972
1975
1978
1980 friend uint32 GetTypeHash(FShaderPipelineType* Ref) { return Ref ? Ref->HashIndex : 0; }
1981 friend uint32 GetTypeHash(const FShaderPipelineType* Ref) { return Ref ? Ref->HashIndex : 0; }
1982
1983 // Check if this pipeline is built of specific types
1984 bool IsGlobalTypePipeline() const { return Stages[0]->GetGlobalShaderType() != nullptr; }
1985 bool IsMaterialTypePipeline() const { return Stages[0]->GetMaterialShaderType() != nullptr; }
1986 bool IsMeshMaterialTypePipeline() const { return Stages[0]->GetMeshMaterialShaderType() != nullptr; }
1987
1989
1991 RENDERCORE_API const FSHAHash& GetSourceHash(EShaderPlatform ShaderPlatform) const;
1992
1994
1996
1997protected:
1998 const TCHAR* const Name;
2002
2003 // Pipeline Stages, ordered from lowest (usually PS) to highest (VS). Guaranteed at least one stage (for VS).
2005
2007
2009
2012
2014};
2015
2016#if !UE_BUILD_DOCS
2017// Vertex+Pixel
2018#define IMPLEMENT_SHADERPIPELINE_TYPE_VSPS(PipelineName, VertexShaderType, PixelShaderType, bRemoveUnused) \
2019 static FShaderPipelineType PipelineName(TEXT(PREPROCESSOR_TO_STRING(PipelineName)), &VertexShaderType::GetStaticType(), nullptr, &PixelShaderType::GetStaticType(), false, bRemoveUnused);
2020// Only VS
2021#define IMPLEMENT_SHADERPIPELINE_TYPE_VS(PipelineName, VertexShaderType, bRemoveUnused) \
2022 static FShaderPipelineType PipelineName(TEXT(PREPROCESSOR_TO_STRING(PipelineName)), &VertexShaderType::GetStaticType(), nullptr, nullptr, false, bRemoveUnused);
2023// Vertex+Geometry+Pixel
2024#define IMPLEMENT_SHADERPIPELINE_TYPE_VSGSPS(PipelineName, VertexShaderType, GeometryShaderType, PixelShaderType, bRemoveUnused) \
2025 static FShaderPipelineType PipelineName(TEXT(PREPROCESSOR_TO_STRING(PipelineName)), &VertexShaderType::GetStaticType(), &GeometryShaderType::GetStaticType(), &PixelShaderType::GetStaticType(), false, bRemoveUnused);
2026// Vertex+Geometry
2027#define IMPLEMENT_SHADERPIPELINE_TYPE_VSGS(PipelineName, VertexShaderType, GeometryShaderType, bRemoveUnused) \
2028 static FShaderPipelineType PipelineName(TEXT(PREPROCESSOR_TO_STRING(PipelineName)), &VertexShaderType::GetStaticType(), &GeometryShaderType::GetStaticType(), nullptr, false, bRemoveUnused);
2029
2030// Mesh+Pixel
2031#define IMPLEMENT_SHADERPIPELINE_TYPE_MSPS(PipelineName, MeshShaderType, PixelShaderType, bRemoveUnused) \
2032 static FShaderPipelineType PipelineName(TEXT(PREPROCESSOR_TO_STRING(PipelineName)), &MeshShaderType::GetStaticType(), nullptr, &PixelShaderType::GetStaticType(), true, bRemoveUnused);
2033// Mesh+Amplification+Pixel
2034#define IMPLEMENT_SHADERPIPELINE_TYPE_MSASPS(PipelineName, MeshShaderType, AmplificationShaderType, PixelShaderType, bRemoveUnused) \
2035 static FShaderPipelineType PipelineName(TEXT(PREPROCESSOR_TO_STRING(PipelineName)), &MeshShaderType::GetStaticType(), &AmplificationShaderType::GetStaticType(), &PixelShaderType::GetStaticType(), true, bRemoveUnused);
2036#endif
2037
2040{
2042public:
2043
2045 : PermutationId(0)
2046 {}
2047
2049 : ShaderTypeName(InShaderType->GetHashedName())
2050 , PermutationId(0)
2051 {
2052 if (InShaderType)
2053 {
2054 SourceHash = InShaderType->GetSourceHash(ShaderPlatform);
2055 }
2056 }
2057
2059 {
2061
2062 Ar << Ref.ShaderTypeName;
2063 Ar << Ref.SourceHash;
2064
2066 {
2067 Ar << Ref.PermutationId;
2068 }
2069
2070 return Ar;
2071 }
2072
2073 bool operator==(const FShaderTypeDependency& Reference) const
2074 {
2075 return ShaderTypeName == Reference.ShaderTypeName && PermutationId == Reference.PermutationId && SourceHash == Reference.SourceHash;
2076 }
2077
2078 bool operator!=(const FShaderTypeDependency& Reference) const
2079 {
2080 return !(*this == Reference);
2081 }
2082
2085
2088
2090 LAYOUT_FIELD(int32, PermutationId);
2091
2094
2095private:
2096#if WITH_EDITOR
2097 // Compact binary API with hidden friend operator<<
2098 RENDERCORE_API void Save(FCbWriter& Writer) const;
2099 bool TryLoad(FCbFieldView Field);
2100 friend inline FCbWriter& operator<<(FCbWriter& Writer, const FShaderTypeDependency& Value)
2101 {
2102 Value.Save(Writer);
2103 return Writer;
2104 }
2106#endif
2107};
2108
2109
2111{
2112public:
2116 {
2118 {
2119 StagesSourceHash = InShaderPipelineType->GetSourceHash(ShaderPlatform);
2120 }
2121 }
2122
2125
2128
2130 {
2131 Ar << Ref.ShaderPipelineTypeName;
2132 Ar << Ref.StagesSourceHash;
2133 return Ar;
2134 }
2135
2136 bool operator==(const FShaderPipelineTypeDependency& Reference) const
2137 {
2138 return ShaderPipelineTypeName == Reference.ShaderPipelineTypeName && StagesSourceHash == Reference.StagesSourceHash;
2139 }
2140
2141 bool operator!=(const FShaderPipelineTypeDependency& Reference) const
2142 {
2143 return !(*this == Reference);
2144 }
2145
2148
2149private:
2150#if WITH_EDITOR
2151 // Compact binary API with hidden friend operator<<
2152 RENDERCORE_API void Save(FCbWriter& Writer) const;
2153 bool TryLoad(FCbFieldView Field);
2154 friend inline FCbWriter& operator<<(FCbWriter& Writer, const FShaderPipelineTypeDependency& Value)
2155 {
2156 Value.Save(Writer);
2157 return Writer;
2158 }
2160#endif
2161};
2162
2165{
2166public:
2167 inline bool operator()(const FShaderType& A, const FShaderType& B ) const
2168 {
2169 int32 AL = FCString::Strlen(A.GetName());
2170 int32 BL = FCString::Strlen(B.GetName());
2171 if ( AL == BL )
2172 {
2173 return FCString::Strncmp(A.GetName(), B.GetName(), AL) > 0;
2174 }
2175 return AL > BL;
2176 }
2177};
2178
2179
2180// A Shader Pipeline instance with compiled stages
2182{
2184public:
2185 explicit FShaderPipeline(const FShaderPipelineType* InType) : TypeName(InType->GetHashedName()) { FMemory::Memzero(&PermutationIds, sizeof(PermutationIds)); }
2187
2188 RENDERCORE_API void AddShader(FShader* Shader, int32 PermutationId);
2190
2191 inline uint32 GetNumShaders() const
2192 {
2193 uint32 NumShaders = 0u;
2194 for (uint32 i = 0u; i < SF_NumGraphicsFrequencies; ++i)
2195 {
2196 if (Shaders[i].IsValid())
2197 {
2198 ++NumShaders;
2199 }
2200 }
2201 return NumShaders;
2202 }
2203
2204 // Find a shader inside the pipeline
2205 template<typename ShaderType>
2207 {
2208 const FShaderType& Type = ShaderType::GetStaticType();
2209 const EShaderFrequency Frequency = Type.GetFrequency();
2211 {
2212 FShader* Shader = Shaders[Frequency].GetChecked();
2213 if (Shader->GetType(InPtrTable) == &Type)
2214 {
2215 return static_cast<ShaderType*>(Shader);
2216 }
2217 }
2218 return nullptr;
2219 }
2220
2226
2228 {
2230 return Shaders[Frequency];
2231 }
2232
2234 {
2236 for (uint32 i = 0u; i < SF_NumGraphicsFrequencies; ++i)
2237 {
2238 if (Shaders[i].IsValid())
2239 {
2240 Result.Add(TShaderRef<FShader>(Shaders[i].GetChecked(), InShaderMap));
2241 }
2242 }
2243 return Result;
2244 }
2245
2247
2249
2251 {
2252 EAll, // All pipelines
2253 EOnlyShared, // Only pipelines with shared shaders
2254 EOnlyUnique, // Only pipelines with unique shaders
2255 };
2256
2258#if WITH_EDITOR
2260#endif // WITH_EDITOR
2261
2265};
2266
2267inline bool operator<(const FShaderPipeline& Lhs, const FShaderPipeline& Rhs)
2268{
2269 return Lhs.TypeName.GetHash() < Rhs.TypeName.GetHash();
2270}
2271
2273{
2274public:
2275 FShaderPipelineRef() : ShaderPipeline(nullptr), ShaderMap(nullptr) {}
2277
2278 inline bool IsValid() const { return ShaderPipeline != nullptr; }
2279 inline bool IsNull() const { return ShaderPipeline == nullptr; }
2280
2281 template<typename ShaderType>
2283 {
2284 return TShaderRef<ShaderType>(ShaderPipeline->GetShader<ShaderType>(GetPointerTable()), *ShaderMap);
2285 }
2286
2288 {
2289 return TShaderRef<FShader>(ShaderPipeline->GetShader(Frequency), *ShaderMap);
2290 }
2291
2293 {
2294 return ShaderPipeline->GetShaders(*ShaderMap);
2295 }
2296
2297 inline FShaderPipeline* GetPipeline() const { return ShaderPipeline; }
2300
2301 inline FShaderPipeline* operator->() const { check(ShaderPipeline); return ShaderPipeline; }
2302
2303private:
2304 FShaderPipeline* ShaderPipeline;
2305 const FShaderMapBase* ShaderMap;
2306};
2307
2308DECLARE_DELEGATE_EightParams(FShaderListReport, const TCHAR*, const TCHAR*, const TCHAR*, const TCHAR*, uint32, uint32, const TCHAR*, void*);
2309
2312{
2314public:
2319
2322
2325
2327
2329
2331 template<typename ShaderType>
2332 ShaderType* GetShader(int32 PermutationId = 0) const
2333 {
2334 FShader* Shader = GetShader(&ShaderType::GetStaticType(), PermutationId);
2335 checkf(Shader != nullptr, TEXT("Failed to find shader type %s in Platform %s"), ShaderType::GetStaticType().GetName(), *LegacyShaderPlatformToShaderFormat(GetShaderPlatform()).ToString());
2336 return static_cast<ShaderType*>(Shader);
2337 }
2338
2340 template<typename ShaderType>
2341 ShaderType* GetShader( const typename ShaderType::FPermutationDomain& PermutationVector ) const
2342 {
2343 return GetShader<ShaderType>( PermutationVector.ToDimensionValueId() );
2344 }
2345
2347 FShader* GetShader(const FShaderType* ShaderType, int32 PermutationId = 0) const
2348 {
2349 return GetShader(ShaderType->GetHashedName(), PermutationId);
2350 }
2351
2353 RENDERCORE_API FShader* GetShader(const FHashedName& TypeName, int32 PermutationId = 0) const;
2354
2356 bool HasShader(const FHashedName& TypeName, int32 PermutationId) const
2357 {
2358 const FShader* Shader = GetShader(TypeName, PermutationId);
2359 return Shader != nullptr;
2360 }
2361
2362 bool HasShader(const FShaderType* Type, int32 PermutationId) const
2363 {
2364 return HasShader(Type->GetHashedName(), PermutationId);
2365 }
2366
2368 {
2369 return Shaders;
2370 }
2371
2373 {
2374 return ShaderPipelines;
2375 }
2376
2377 RENDERCORE_API void AddShader(const FHashedName& TypeName, int32 PermutationId, FShader* Shader);
2378
2379 RENDERCORE_API FShader* FindOrAddShader(const FHashedName& TypeName, int32 PermutationId, FShader* Shader);
2380
2382
2384
2389 RENDERCORE_API void RemoveShaderTypePermutaion(const FHashedName& TypeName, int32 PermutationId);
2390
2391 inline void RemoveShaderTypePermutaion(const FShaderType* Type, int32 PermutationId)
2392 {
2393 RemoveShaderTypePermutaion(Type->GetHashedName(), PermutationId);
2394 }
2395
2397
2398#if !UE_BUILD_SHIPPING
2400#endif // !UE_BUILD_SHIPPING
2401
2404
2407
2410
2411#if WITH_EDITOR
2413
2415
2417#endif // WITH_EDITOR
2418
2419#if WITH_EDITORONLY_DATA
2421#endif // WITH_EDITORONLY_DATA
2422
2424 inline bool IsEmpty() const
2425 {
2426 return Shaders.Num() == 0;
2427 }
2428
2431
2434 {
2435 return ShaderPipelines.Num();
2436 }
2437
2439 RENDERCORE_API void Empty();
2440
2442 {
2444 return (Index != INDEX_NONE) ? ShaderPipelines[Index].Get() : nullptr;
2445 }
2446
2447 inline FShaderPipeline* GetShaderPipeline(const FShaderPipelineType* PipelineType) const
2448 {
2449 return GetShaderPipeline(PipelineType->GetHashedName());
2450 }
2451
2452 inline bool HasShaderPipeline(const FHashedName& PipelineTypeName) const { return GetShaderPipeline(PipelineTypeName) != nullptr; }
2453 inline bool HasShaderPipeline(const FShaderPipelineType* PipelineType) const { return (GetShaderPipeline(PipelineType) != nullptr); }
2454
2456
2458
2459 RENDERCORE_API void UpdateHash(FSHA1& Hasher) const;
2460
2461protected:
2463
2465
2472 LAYOUT_FIELD(FMemoryImageName, ShaderPlatformName);
2473};
2474
2476{
2477public:
2479
2481
2482 inline FShaderMapResource* GetResource() const { return Resource; }
2483 inline FShaderMapResource* GetResourceChecked() const { check(Resource); return Resource; }
2484 inline const FShaderMapPointerTable& GetPointerTable() const { check(PointerTable); return *PointerTable; }
2485 inline const FShaderMapContent* GetContent() const { return Content.Object; }
2487 {
2489 return Content.Object;
2490 }
2494
2495#if !UE_BUILD_SHIPPING
2496 virtual void DumpShaderList(FShaderListReport& Out) const
2497 {
2498 GetContent()->DumpShaderList(*this, Out);
2499 }
2500#endif // !UE_BUILD_SHIPPING
2501
2502 inline EShaderPlatform GetShaderPlatform() const { return Content.Object ? Content.Object->GetShaderPlatform() : SP_NumPlatforms; }
2503 inline uint32 GetFrozenContentSize() const { return Content.FrozenSize; }
2504
2506
2510
2512 {
2513 return PermutationFlags;
2514 }
2515
2516 RENDERCORE_API FString ToString() const;
2517
2518#if WITH_EDITORONLY_DATA
2521#endif
2522
2523#if WITH_EDITOR
2525 {
2527 }
2528 void SaveShaderStableKeys(EShaderPlatform TargetShaderPlatform, const struct FStableShaderKeyAndValue& SaveKeyVal)
2529 {
2530 Content.Object->SaveShaderStableKeys(*this, TargetShaderPlatform, SaveKeyVal);
2531 }
2532
2536 void AssociateWithAsset(const FName& AssetPath)
2537 {
2538 AssociatedAssets.Add(AssetPath);
2539 }
2540
2541 void AssociateWithAssets(const FShaderMapAssetPaths& AssetPaths)
2542 {
2543 AssociatedAssets.Append(AssetPaths);
2544 }
2545
2547 {
2548 return AssociatedAssets;
2549 }
2550#endif // WITH_EDITOR
2551
2552protected:
2554
2555 RENDERCORE_API void AssignCopy(const FShaderMapBase& Source);
2556
2559
2560protected:
2561 virtual const FTypeLayoutDesc& GetContentTypeDesc() const = 0;
2563 virtual void PostFinalizeContent() { }
2564
2565private:
2566#if WITH_EDITOR
2569#endif
2572 FShaderMapPointerTable* PointerTable;
2574 uint32 NumFrozenShaders;
2575 EShaderPermutationFlags PermutationFlags;
2576};
2577
2578template<typename ContentType, typename PointerTableType = FShaderMapPointerTable>
2580{
2581public:
2582 inline const PointerTableType& GetPointerTable() const { return static_cast<const PointerTableType&>(FShaderMapBase::GetPointerTable()); }
2583 inline const ContentType* GetContent() const { return static_cast<const ContentType*>(FShaderMapBase::GetContent()); }
2584 inline ContentType* GetMutableContent() { return static_cast<ContentType*>(FShaderMapBase::GetMutableContent()); }
2585
2587 {
2588 ContentType* LocalContent = this->GetMutableContent();
2589 check(LocalContent);
2590 LocalContent->Finalize(this->GetResourceCode());
2591 LocalContent->Validate(*this);
2593 }
2594
2595protected:
2596 virtual const FTypeLayoutDesc& GetContentTypeDesc() const final override { return StaticGetTypeLayoutDesc<ContentType>(); }
2597 virtual FShaderMapPointerTable* CreatePointerTable() const final override { return new PointerTableType(); }
2598};
2599
2600template<typename ShaderType, typename PointerTableType>
2602{
2603 checkSlow(ShaderMap);
2604 return static_cast<const PointerTableType&>(ShaderMap->GetPointerTable());
2605}
2606
2607template<typename ShaderType, typename PointerTableType>
2609{
2610 checkSlow(ShaderMap);
2611 return ShaderMap->GetResource();
2612}
2613
2615{
2616 checkSlow(ShaderMap);
2617 return ShaderMap->GetPointerTable();
2618}
2619
2621{
2622 checkSlow(ShaderMap);
2623 return ShaderMap->GetResource();
2624}
2625
2627template<typename ShaderType>
2628class TShaderMapRef : public TShaderRef<ShaderType>
2629{
2630public:
2631 TShaderMapRef(const typename ShaderType::ShaderMapType* ShaderIndex)
2632 : TShaderRef<ShaderType>(ShaderIndex->template GetShader<ShaderType>(/* PermutationId = */ 0)) // gcc3 needs the template quantifier so it knows the < is not a less-than
2633 {
2634 static_assert(
2635 std::is_same_v<typename ShaderType::FPermutationDomain, FShaderPermutationNone>,
2636 "Missing permutation vector argument for shader that have a permutation domain.");
2637 }
2638
2640 const typename ShaderType::ShaderMapType* ShaderIndex,
2641 const typename ShaderType::FPermutationDomain& PermutationVector)
2642 : TShaderRef<ShaderType>(ShaderIndex->template GetShader<ShaderType>(PermutationVector.ToDimensionValueId())) // gcc3 needs the template quantifier so it knows the < is not a less-than
2643 { }
2644};
2645
2647template<typename ShaderType>
2648class TOptionalShaderMapRef : public TShaderRef<ShaderType>
2649{
2650public:
2651 TOptionalShaderMapRef(const typename ShaderType::ShaderMapType* ShaderIndex):
2652 TShaderRef<ShaderType>(TShaderRef<ShaderType>::Cast(ShaderIndex->GetShader(&ShaderType::GetStaticType()))) // gcc3 needs the template quantifier so it knows the < is not a less-than
2653 {}
2654};
2655
2662
2668
2675
2678 FRHIComputeCommandList& RHICmdList,
2679 FShader* Shader,
2680 uint32 ThreadGroupCountX,
2681 uint32 ThreadGroupCountY,
2682 uint32 ThreadGroupCountZ);
2683
2686 FRHIComputeCommandList& RHICmdList,
2687 FShader* Shader,
2688 FRHIBuffer* ArgumentBuffer,
2689 uint32 ArgumentOffset);
2690
2692 FRHIComputeCommandList& RHICmdList,
2694 uint32 ThreadGroupCountX,
2695 uint32 ThreadGroupCountY,
2696 uint32 ThreadGroupCountZ)
2697{
2698 DispatchComputeShader(RHICmdList, Shader.GetShader(), ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
2699}
2700
2703
2706
2708extern RENDERCORE_API void ShaderMapAppendKeyString(EShaderPlatform Platform, FString& KeyString);
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
bool LoadFromCompactBinary(FCbFieldView Field, FAssetDependency &Dependency)
Definition AssetRegistry.cpp:10420
#define WITH_EDITOR
Definition Build.h:67
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UNLIKELY(x)
Definition Platform.h:857
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define DECLARE_DELEGATE_EightParams(DelegateName, Param1Type, Param2Type, Param3Type, Param4Type, Param5Type, Param6Type, Param7Type, Param8Type)
Definition DelegateCombinations.h:111
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
#define LAYOUT_FIELD(T, Name,...)
Definition MemoryLayout.h:471
#define DECLARE_EXPORTED_TYPE_LAYOUT(T, RequiredAPI, Interface)
Definition MemoryLayout.h:559
#define DECLARE_EXPORTED_TEMPLATE_INTRINSIC_TYPE_LAYOUT(TemplatePrefix, T, RequiredAPI)
Definition MemoryLayout.h:706
#define LAYOUT_FIELD_EDITORONLY(T, Name,...)
Definition MemoryLayout.h:488
@ Num
Definition MetalRHIPrivate.h:234
const bool
Definition NetworkReplayStreaming.h:178
EShaderFrequency
Definition RHIDefinitions.h:202
@ SF_NumGraphicsFrequencies
Definition RHIDefinitions.h:219
@ SF_Compute
Definition RHIDefinitions.h:208
@ SF_NumFrequencies
Definition RHIDefinitions.h:216
@ SF_Amplification
Definition RHIDefinitions.h:205
@ SF_Vertex
Definition RHIDefinitions.h:203
@ SF_Mesh
Definition RHIDefinitions.h:204
@ SF_Geometry
Definition RHIDefinitions.h:207
@ SF_RayGen
Definition RHIDefinitions.h:209
@ SF_RayCallable
Definition RHIDefinitions.h:212
@ SF_RayMiss
Definition RHIDefinitions.h:210
@ SF_RayHitGroup
Definition RHIDefinitions.h:211
@ SF_Pixel
Definition RHIDefinitions.h:206
EUniformBufferBaseType
Definition RHIDefinitions.h:634
bool IsWorkGraphShaderFrequency(EShaderFrequency Frequency)
Definition RHIDefinitions.h:1702
bool IsValidGraphicsFrequency(EShaderFrequency InShaderFrequency)
Definition RHIDefinitions.h:228
EShaderPlatform
Definition RHIShaderPlatform.h:11
@ SP_NumBits
Definition RHIShaderPlatform.h:56
@ SP_NumPlatforms
Definition RHIShaderPlatform.h:55
FName LegacyShaderPlatformToShaderFormat(EShaderPlatform Platform)
Definition RHIStrings.cpp:237
EShaderPlatform GMaxRHIShaderPlatform
Definition RHI.cpp:1335
EShaderParameterType
Definition ShaderCore.h:248
EShaderCompileJobPriority
Definition ShaderCore.h:803
TShaderPermutationDomain<> FShaderPermutationNone
Definition ShaderPermutation.h:467
EShaderPermutationFlags
Definition ShaderPermutation.h:19
RENDERCORE_API uint32 GetRayTracingPayloadTypeMaxSize(ERayTracingPayloadType PayloadType)
Definition Shader.cpp:2956
RENDERCORE_API void DispatchComputeShader(FRHIComputeCommandList &RHICmdList, FShader *Shader, uint32 ThreadGroupCountX, uint32 ThreadGroupCountY, uint32 ThreadGroupCountZ)
Definition Shader.cpp:1631
int16 GetParameterIndex(const FShaderParameterBindings::FResourceParameter &Parameter)
Definition Shader.h:802
EShaderPermutationPrecacheRequest
Definition Shader.h:807
bool operator<(const FShaderPipeline &Lhs, const FShaderPipeline &Rhs)
Definition Shader.h:2267
RENDERCORE_API EShaderPermutationFlags GetShaderPermutationFlags(const FPlatformTypeLayoutParameters &LayoutParams)
Definition Shader.cpp:2934
const int32 kUniqueShaderPermutationId
Definition Shader.h:121
RENDERCORE_API bool IsUsingEmulatedUniformBuffers(EShaderPlatform Platform)
Definition Shader.cpp:1676
RENDERCORE_API void ShaderMapAppendKey(EShaderPlatform Platform, FShaderKeyGenerator &KeyGen)
Definition Shader.cpp:1692
RENDERCORE_API void DispatchIndirectComputeShader(FRHIComputeCommandList &RHICmdList, FShader *Shader, FRHIBuffer *ArgumentBuffer, uint32 ArgumentOffset)
Definition Shader.cpp:1641
#define SHADER_TYPE_LIST
Definition Shader.h:1222
uint32(* TRaytracingPayloadSizeFunction)()
Definition Shader.h:316
RENDERCORE_API void DumpShaderPipelineStats(EShaderPlatform Platform)
Definition Shader.cpp:1580
TSet< FName > FShaderMapAssetPaths
Definition Shader.h:88
RENDERCORE_API void ShaderMapAppendKeyString(EShaderPlatform Platform, FString &KeyString)
Definition Shader.cpp:1686
RENDERCORE_API void SetAdditionalShaderPermutationFlags(EShaderPermutationFlags AdditionalFlags)
Definition Shader.cpp:2928
RENDERCORE_API bool IsDxcEnabledForPlatform(EShaderPlatform Platform, bool bHlslVersion2021=false)
Definition Shader.cpp:1650
RENDERCORE_API FShaderType * FindShaderTypeByName(const FHashedName &ShaderTypeName)
Definition Shader.cpp:1620
RENDERCORE_API void DumpShaderStats(EShaderPlatform Platform, EShaderFrequency Frequency)
Definition Shader.cpp:1449
FString LexToString(FShaderType::EShaderTypeForDynamicCast ShaderType)
Definition Shader.h:1568
RENDERCORE_API const FTypeLayoutDesc & GetTypeLayoutDesc(const FPointerTableBase *PtrTable, const FShader &Shader)
Definition Shader.cpp:964
RENDERCORE_API void RegisterRayTracingPayloadType(ERayTracingPayloadType PayloadType, uint32 PayloadSize, TRaytracingPayloadSizeFunction PayloadSizeFunction)
Definition Shader.cpp:2944
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint32 Size
Definition VulkanMemory.cpp:4034
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
virtual CORE_API void UsingCustomVersion(const struct FGuid &Guid)
Definition Archive.cpp:590
CORE_API int32 CustomVer(const struct FGuid &Key) const
Definition Archive.cpp:602
Definition CompactBinary.h:610
Definition CompactBinaryWriter.h:68
Definition Shader.h:2165
bool operator()(const FShaderType &A, const FShaderType &B) const
Definition Shader.h:2167
Definition CompressedBuffer.h:50
Definition RenderDeferredCleanup.h:11
Definition GlobalShader.h:87
Definition MemoryImage.h:858
Definition MaterialShaderType.h:95
Definition MaterialShared.h:2058
Definition MemoryImageWriter.h:14
Definition MemoryImageWriter.h:78
Definition MeshMaterialShaderType.h:26
Definition NameTypes.h:617
Definition MemoryImage.h:49
Definition RHIResources.h:966
Definition RHIResources.h:1581
Definition RHICommandList.h:2735
Definition RHIResources.h:1018
Definition RHIResources.h:978
Definition RHIResources.h:947
Definition RHIResources.h:960
Definition RHIResources.h:972
Definition RHIResources.h:984
Definition RHIShaderBindingLayout.h:72
Definition RHIResources.h:854
EShaderFrequency GetFrequency() const
Definition RHIResources.h:911
Definition RHIResources.h:954
Definition RHIResources.h:1033
Definition RenderResource.h:37
Definition SecureHash.h:314
Definition SecureHash.h:226
Definition ShaderCore.h:466
Definition Shader.h:695
const FVertexFactoryType * VFType
Definition Shader.h:708
friend bool operator!=(const FShaderId &X, const FShaderId &Y)
Definition Shader.h:734
const FShaderType * Type
Definition Shader.h:707
int32 PermutationId
Definition Shader.h:711
FHashedName ShaderPipelineName
Definition Shader.h:709
friend bool operator==(const FShaderId &X, const FShaderId &Y)
Definition Shader.h:724
FShaderId(const FShaderType *InType, const FSHAHash &InMaterialShaderMapHash, const FHashedName &InShaderPipeline, const FVertexFactoryType *InVertexFactoryType, int32 InPermutationId, EShaderPlatform InPlatform)
Definition Shader.h:698
friend uint32 GetTypeHash(const FShaderId &Id)
Definition Shader.h:714
FSHAHash MaterialShaderMapHash
Definition Shader.h:710
uint32 Platform
Definition Shader.h:712
FShaderId()
Definition Shader.h:697
Definition ShaderKeyGenerator.h:29
Definition Shader.h:654
FVertexFactoryType * VertexFactoryType
Definition Shader.h:683
const FShaderPipelineType * ShaderPipeline
Definition Shader.h:684
int32 PermutationId
Definition Shader.h:686
FShaderKey(const FSHAHash &InMaterialShaderMapHash, const FShaderPipelineType *InShaderPipeline, FVertexFactoryType *InVertexFactoryType, int32 PermutationId, EShaderPlatform InPlatform)
Definition Shader.h:656
FSHAHash MaterialShaderMapHash
Definition Shader.h:685
uint32 Platform
Definition Shader.h:687
friend uint32 GetTypeHash(const FShaderKey &Id)
Definition Shader.h:664
RENDERCORE_API friend FArchive & operator<<(FArchive &Ar, FShaderKey &Ref)
friend bool operator==(const FShaderKey &X, const FShaderKey &Y)
Definition Shader.h:672
Definition Shader.h:251
FShaderLooseParameterBufferInfo(uint16 InBufferIndex, uint16 InBufferSize)
Definition Shader.h:261
friend FArchive & operator<<(FArchive &Ar, FShaderLooseParameterBufferInfo &Info)
Definition Shader.h:268
bool operator<(const FShaderLooseParameterBufferInfo &Rhs) const
Definition Shader.h:283
LAYOUT_FIELD(uint16, BaseIndex)
FShaderLooseParameterBufferInfo()
Definition Shader.h:259
bool operator==(const FShaderLooseParameterBufferInfo &Rhs) const
Definition Shader.h:276
LAYOUT_FIELD(TMemoryImageArray< FShaderLooseParameterInfo >, Parameters)
Definition Shader.h:216
LAYOUT_FIELD(uint16, BaseIndex)
FShaderLooseParameterInfo()=default
friend FArchive & operator<<(FArchive &Ar, FShaderLooseParameterInfo &Info)
Definition Shader.h:231
bool operator<(const FShaderLooseParameterInfo &Rhs) const
Definition Shader.h:244
bool operator==(const FShaderLooseParameterInfo &Rhs) const
Definition Shader.h:238
LAYOUT_FIELD(uint16, Size)
FShaderLooseParameterInfo(uint16 InBaseIndex, uint16 InSize)
Definition Shader.h:224
Definition Shader.h:2476
EShaderPermutationFlags GetPermutationFlags() const
Definition Shader.h:2511
FShaderMapResource * GetResourceChecked() const
Definition Shader.h:2483
RENDERCORE_API FString ToString() const
Definition ShaderMap.cpp:465
RENDERCORE_API void InitResource()
Definition ShaderMap.cpp:233
RENDERCORE_API void AssignContent(TMemoryImageObject< FShaderMapContent > InContent)
Definition ShaderMap.cpp:184
virtual RENDERCORE_API ~FShaderMapBase()
Definition ShaderMap.cpp:158
virtual void GetShaderPipelineList(TArray< FShaderPipelineRef > &OutShaderPipelines) const =0
const FShaderMapPointerTable & GetPointerTable() const
Definition Shader.h:2484
uint32 GetFrozenContentSize() const
Definition Shader.h:2503
virtual void GetShaderList(TMap< FHashedName, TShaderRef< FShader > > &OutShaders) const =0
EShaderPlatform GetShaderPlatform() const
Definition Shader.h:2502
FShaderMapContent * GetMutableContent()
Definition Shader.h:2486
RENDERCORE_API FShaderMapBase()
Definition ShaderMap.cpp:142
const FShaderMapContent * GetContent() const
Definition Shader.h:2485
RENDERCORE_API void DestroyContent()
Definition ShaderMap.cpp:487
virtual const FTypeLayoutDesc & GetContentTypeDesc() const =0
RENDERCORE_API FShaderMapResourceCode * GetResourceCode()
Definition ShaderMap.cpp:175
FShaderMapResource * GetResource() const
Definition Shader.h:2482
RENDERCORE_API void FinalizeContent()
Definition ShaderMap.cpp:245
virtual FShaderMapPointerTable * CreatePointerTable() const =0
RENDERCORE_API void UnfreezeContent()
Definition ShaderMap.cpp:264
RENDERCORE_API void AssignCopy(const FShaderMapBase &Source)
Definition ShaderMap.cpp:197
virtual void DumpShaderList(FShaderListReport &Out) const
Definition Shader.h:2496
virtual void PostFinalizeContent()
Definition Shader.h:2563
Definition Shader.h:2312
RENDERCORE_API void GetShaderList(const FShaderMapBase &InShaderMap, const FSHAHash &InMaterialShaderMapHash, TMap< FShaderId, TShaderRef< FShader > > &OutShaders) const
Definition ShaderMap.cpp:731
TArrayView< const TMemoryImagePtr< FShaderPipeline > > GetShaderPipelines() const
Definition Shader.h:2372
FShaderPipeline * GetShaderPipeline(const FShaderPipelineType *PipelineType) const
Definition Shader.h:2447
FShaderPipeline * GetShaderPipeline(const FHashedName &PipelineTypeName) const
Definition Shader.h:2441
bool HasShaderPipeline(const FShaderPipelineType *PipelineType) const
Definition Shader.h:2453
RENDERCORE_API void RemoveShaderPipelineType(const FShaderPipelineType *ShaderPipelineType)
Definition ShaderMap.cpp:645
RENDERCORE_API uint32 GetMaxNumInstructionsForShader(const FShaderMapBase &InShaderMap, FShaderType *ShaderType) const
Definition ShaderMap.cpp:911
RENDERCORE_API void UpdateHash(FSHA1 &Hasher) const
Definition ShaderMap.cpp:1017
TArrayView< const TMemoryImagePtr< FShader > > GetShaders() const
Definition Shader.h:2367
RENDERCORE_API void Validate(const FShaderMapBase &InShaderMap) const
Definition ShaderMap.cpp:805
void RemoveShaderTypePermutaion(const FShaderType *Type, int32 PermutationId)
Definition Shader.h:2391
bool HasShaderPipeline(const FHashedName &PipelineTypeName) const
Definition Shader.h:2452
ShaderType * GetShader(const typename ShaderType::FPermutationDomain &PermutationVector) const
Definition Shader.h:2341
RENDERCORE_API ~FShaderMapContent()
Definition ShaderMap.cpp:513
RENDERCORE_API FShaderPipeline * FindOrAddShaderPipeline(FShaderPipeline *Pipeline)
Definition ShaderMap.cpp:589
RENDERCORE_API void Empty()
Definition ShaderMap.cpp:1034
LAYOUT_FIELD(FMemoryImageHashTable, ShaderHash)
LAYOUT_FIELD(TMemoryImageArray< TMemoryImagePtr< FShader > >, Shaders)
RENDERCORE_API void GetShaderPipelineList(const FShaderMapBase &InShaderMap, TArray< FShaderPipelineRef > &OutShaderPipelines, FShaderPipeline::EFilter Filter) const
Definition ShaderMap.cpp:787
uint32 GetNumShaderPipelines() const
Definition Shader.h:2433
LAYOUT_FIELD(TMemoryImageArray< TMemoryImagePtr< FShaderPipeline > >, ShaderPipelines)
bool HasShader(const FShaderType *Type, int32 PermutationId) const
Definition Shader.h:2362
RENDERCORE_API void AddShaderPipeline(FShaderPipeline *Pipeline)
Definition ShaderMap.cpp:582
FShader * GetShader(const FShaderType *ShaderType, int32 PermutationId=0) const
Definition Shader.h:2347
RENDERCORE_API FShader * FindOrAddShader(const FHashedName &TypeName, int32 PermutationId, FShader *Shader)
Definition ShaderMap.cpp:559
RENDERCORE_API void EmptyShaderPipelines()
Definition ShaderMap.cpp:1048
LAYOUT_FIELD(TMemoryImageArray< int32 >, ShaderPermutations)
RENDERCORE_API void AddShader(const FHashedName &TypeName, int32 PermutationId, FShader *Shader)
Definition ShaderMap.cpp:545
RENDERCORE_API void DumpShaderList(const FShaderMapBase &InShaderMap, FShaderListReport &Out) const
Definition ShaderMap.cpp:672
RENDERCORE_API EShaderPlatform GetShaderPlatform() const
Definition ShaderMap.cpp:518
LAYOUT_FIELD(FMemoryImageName, ShaderPlatformName)
RENDERCORE_API void RemoveShaderTypePermutaion(const FHashedName &TypeName, int32 PermutationId)
Definition ShaderMap.cpp:610
bool HasShader(const FHashedName &TypeName, int32 PermutationId) const
Definition Shader.h:2356
RENDERCORE_API uint32 GetNumShaders() const
Definition ShaderMap.cpp:901
bool IsEmpty() const
Definition Shader.h:2424
ShaderType * GetShader(int32 PermutationId=0) const
Definition Shader.h:2332
LAYOUT_FIELD(TMemoryImageArray< FHashedName >, ShaderTypes)
Definition Shader.h:637
TPtrTable< FShaderType > ShaderTypes
Definition Shader.h:647
virtual FShaderMapPointerTable * Clone() const
Definition Shader.h:642
TPtrTable< FVertexFactoryType > VFTypes
Definition Shader.h:648
virtual RENDERCORE_API void * GetIndexedPointer(const FTypeLayoutDesc &TypeDesc, uint32 i) const override
Definition Shader.cpp:641
virtual RENDERCORE_API void SaveToArchive(FArchive &Ar, const FPlatformTypeLayoutParameters &LayoutParams, const void *FrozenObject) const override
Definition Shader.cpp:649
virtual RENDERCORE_API int32 AddIndexedPointer(const FTypeLayoutDesc &TypeDesc, void *Ptr) override
Definition Shader.cpp:633
virtual RENDERCORE_API bool LoadFromArchive(FArchive &Ar, const FPlatformTypeLayoutParameters &LayoutParams, void *FrozenObject) override
Definition Shader.cpp:674
Definition Shader.h:521
RENDERCORE_API ~FShaderMapResourceCode()
Definition ShaderResource.cpp:226
FShaderMapResourceCode()
Definition Shader.h:571
TArray< FSHAHash > ShaderHashes
Definition Shader.h:602
void AddShaderCompilerOutput(const FShaderCompilerOutput &Output, const FString &DebugName=FString(), FString DebugInfo=FString())
Definition Shader.h:585
RENDERCORE_API uint32 GetSizeBytes() const
Definition ShaderResource.cpp:245
TArray< FShaderCodeResource > ShaderCodeResources
Definition Shader.h:604
RENDERCORE_API void Finalize()
Definition ShaderResource.cpp:232
FSHAHash ResourceHash
Definition Shader.h:601
int32 FindShaderIndex(const FSHAHash &InHash) const
Definition ShaderResource.cpp:256
Definition Shader.h:618
virtual RENDERCORE_API FRHIShader * CreateRHIShaderOrCrash(int32 ShaderIndex, bool bRequired) override
Definition ShaderResource.cpp:711
virtual RENDERCORE_API FSHAHash GetShaderHash(int32 ShaderIndex) override
Definition ShaderResource.cpp:706
TRefCountPtr< FShaderMapResourceCode > Code
Definition Shader.h:633
virtual uint32 GetSizeBytes() const override
Definition ShaderResource.cpp:788
virtual FString GetFriendlyName() const override
Definition Shader.h:628
virtual uint32 GetShaderSizeBytes(int32 ShaderIndex) const override
Definition ShaderResource.cpp:803
FShaderMapResource_InlineCode(EShaderPlatform InPlatform, FShaderMapResourceCode *InCode)
Definition Shader.h:620
Definition Shader.h:336
RENDERCORE_API void BeginCreateAllShaders()
Definition ShaderResource.cpp:613
RENDERCORE_API void ReleaseShaders()
Definition ShaderResource.cpp:536
virtual FSHAHash GetShaderHash(int32 ShaderIndex)=0
virtual void PreloadShader(int32 ShaderIndex, FGraphEventArray &OutCompletionEvents)
Definition Shader.h:366
virtual FRHIShader * CreateRHIShaderOrCrash(int32 ShaderIndex, bool bRequired)=0
bool HasShader(int32 ShaderIndex) const
Definition Shader.h:359
virtual bool TryRelease()
Definition Shader.h:489
static RENDERCORE_API bool ArePlatformsCompatible(EShaderPlatform CurrentPlatform, EShaderPlatform TargetPlatform)
Definition ShaderResource.cpp:75
virtual int32 GetGroupIndexForShader(int32 ShaderIndex) const
Definition Shader.h:376
virtual RENDERCORE_API ~FShaderMapResource()
Definition ShaderResource.cpp:504
virtual void ReleasePreloadedShaderCode(int32 ShaderIndex)
Definition Shader.h:487
int32 GetNumRefs() const
Definition Shader.h:344
virtual uint32 GetShaderSizeBytes(int32 ShaderIndex) const
Definition ShaderResource.cpp:515
virtual RENDERCORE_API void ReleaseRHI() override
Definition ShaderResource.cpp:578
bool ContainsAtLeastOneRHIShaderCreated() const
Definition Shader.h:394
SIZE_T GetAllocatedSize() const
Definition Shader.h:474
virtual uint32 GetSizeBytes() const =0
RENDERCORE_API void Release()
Definition ShaderResource.cpp:521
EShaderPlatform GetPlatform() const
Definition Shader.h:340
virtual void PreloadShaderMap(FGraphEventArray &OutCompletionEvents)
Definition Shader.h:371
virtual int32 GetLibraryId() const
Definition Shader.h:382
FRHIShader * GetShader(int32 ShaderIndex, bool bRequired=true)
Definition Shader.h:399
virtual FSHAHash GetShaderMapHash() const
Definition Shader.h:416
RENDERCORE_API void AddRef()
Definition ShaderResource.cpp:510
virtual int32 GetLibraryShaderIndex(int32 ShaderIndex) const
Definition Shader.h:388
int32 GetNumShaders() const
Definition Shader.h:349
bool IsValidShaderIndex(int32 ShaderIndex) const
Definition Shader.h:354
Definition Shader.h:746
LAYOUT_FIELD(TMemoryImageArray< FBindlessResourceParameter >, BindlessResourceParameters)
LAYOUT_FIELD(TMemoryImageArray< FResourceParameter >, ResourceParameters)
static constexpr uint16 kInvalidBufferIndex
Definition Shader.h:783
RENDERCORE_API void BindForLegacyShaderParameters(const FShader *Shader, int32 PermutationId, const FShaderParameterMap &ParameterMaps, const FShaderParametersMetadata &StructMetaData, bool bShouldBindEverything=false)
Definition ShaderParameterStruct.cpp:250
LAYOUT_FIELD_INITIALIZED(uint32, StructureLayoutHash, 0)
RENDERCORE_API void BindForRootShaderParameters(const FShader *Shader, int32 PermutationId, const FShaderParameterMap &ParameterMaps)
Definition ShaderParameterStruct.cpp:332
LAYOUT_FIELD(TMemoryImageArray< FParameterStructReference >, ParameterReferences)
LAYOUT_FIELD_INITIALIZED(uint16, RootParameterBufferIndex, FShaderParameterBindings::kInvalidBufferIndex)
DECLARE_EXPORTED_TYPE_LAYOUT(FShaderParameterBindings, RENDERCORE_API, NonVirtual)
LAYOUT_FIELD(TMemoryImageArray< FParameterStructReference >, GraphUniformBuffers)
LAYOUT_FIELD(TMemoryImageArray< FParameter >, Parameters)
Definition Shader.h:290
LAYOUT_FIELD(TMemoryImageArray< FShaderLooseParameterBufferInfo >, LooseParameterBuffers)
friend FArchive & operator<<(FArchive &Ar, FShaderParameterMapInfo &Info)
Definition Shader.h:299
LAYOUT_FIELD(TMemoryImageArray< FShaderResourceParameterInfo >, TextureSamplers)
LAYOUT_FIELD(uint64, Hash)
LAYOUT_FIELD(TMemoryImageArray< FShaderUniformBufferParameterInfo >, UniformBuffers)
LAYOUT_FIELD(TMemoryImageArray< FShaderResourceParameterInfo >, SRVs)
bool operator==(const FShaderParameterMapInfo &Rhs) const
Definition Shader.h:309
Definition ShaderCore.h:323
Definition ShaderParameterMetadata.h:136
Definition Shader.h:2273
FShaderPipeline * operator->() const
Definition Shader.h:2301
FShaderMapResource * GetResource() const
Definition Shader.h:2620
const FShaderMapPointerTable & GetPointerTable() const
Definition Shader.h:2614
bool IsNull() const
Definition Shader.h:2279
TArray< TShaderRef< FShader > > GetShaders() const
Definition Shader.h:2292
bool IsValid() const
Definition Shader.h:2278
TShaderRef< FShader > GetShader(EShaderFrequency Frequency) const
Definition Shader.h:2287
FShaderPipeline * GetPipeline() const
Definition Shader.h:2297
FShaderPipelineRef()
Definition Shader.h:2275
TShaderRef< ShaderType > GetShader() const
Definition Shader.h:2282
FShaderPipelineRef(FShaderPipeline *InPipeline, const FShaderMapBase &InShaderMap)
Definition Shader.h:2276
Definition Shader.h:2111
FShaderPipelineTypeDependency(const FShaderPipelineType *InShaderPipelineType, EShaderPlatform ShaderPlatform)
Definition Shader.h:2114
bool operator!=(const FShaderPipelineTypeDependency &Reference) const
Definition Shader.h:2141
bool operator==(const FShaderPipelineTypeDependency &Reference) const
Definition Shader.h:2136
RENDERCORE_API void RefreshCachedSourceHash(EShaderPlatform ShaderPlatform)
Definition Shader.cpp:1287
friend FArchive & operator<<(FArchive &Ar, class FShaderPipelineTypeDependency &Ref)
Definition Shader.h:2129
FShaderPipelineTypeDependency()
Definition Shader.h:2113
FSHAHash StagesSourceHash
Definition Shader.h:2127
FHashedName ShaderPipelineTypeName
Definition Shader.h:2124
Definition Shader.h:1931
const FShaderType * GetShader(EShaderFrequency Frequency) const
Definition Shader.h:1948
TArray< const FShaderType * > Stages
Definition Shader.h:2004
static RENDERCORE_API const FShaderPipelineType * GetShaderPipelineTypeByName(const FHashedName &Name)
Definition Shader.cpp:1224
bool IsGlobalTypePipeline() const
Definition Shader.h:1984
static RENDERCORE_API TArray< const FShaderPipelineType * > GetShaderPipelineTypesByFilenameFilter(const TFunction< bool(const TCHAR *)> &InFilenameFilter)
Definition Shader.cpp:1143
RENDERCORE_API bool ShouldOptimizeUnusedOutputs(EShaderPlatform Platform) const
Definition Shader.cpp:1230
const TCHAR *const Name
Definition Shader.h:1998
bool HasMeshShader() const
Definition Shader.h:1944
FName TypeName
Definition Shader.h:1999
bool bShouldOptimizeUnusedOutputs
Definition Shader.h:2011
friend uint32 GetTypeHash(const FShaderPipelineType *Ref)
Definition Shader.h:1981
FHashedName HashedName
Definition Shader.h:2000
TLinkedList< FShaderPipelineType * > GlobalListLink
Definition Shader.h:2008
static RENDERCORE_API const TArray< FShaderPipelineType * > & GetSortedTypes(FShaderType::EShaderTypeForDynamicCast Type)
Definition Shader.cpp:1115
static RENDERCORE_API bool bInitialized
Definition Shader.h:2013
FHashedName HashedPrimaryShaderFilename
Definition Shader.h:2001
const FHashedName & GetHashedPrimaryShaderFilename() const
Definition Shader.h:1957
friend uint32 GetTypeHash(FShaderPipelineType *Ref)
Definition Shader.h:1980
const FShaderType * AllStages[SF_NumFrequencies]
Definition Shader.h:2006
FName GetFName() const
Definition Shader.h:1954
static RENDERCORE_API void Initialize()
Definition Shader.cpp:1161
RENDERCORE_API bool ShouldCompilePermutation(const FShaderPermutationParameters &Parameters) const
Definition Shader.cpp:1245
bool HasGeometry() const
Definition Shader.h:1945
bool IsMeshMaterialTypePipeline() const
Definition Shader.h:1986
RENDERCORE_API friend FArchive & operator<<(FArchive &Ar, const FShaderPipelineType *&Ref)
Definition Shader.cpp:149
RENDERCORE_API ~FShaderPipelineType()
Definition Shader.cpp:1093
uint32 HashIndex
Definition Shader.h:2010
TCHAR const * GetName() const
Definition Shader.h:1955
RENDERCORE_API EShaderPermutationPrecacheRequest ShouldPrecachePermutation(const FShaderPermutationParameters &Parameters) const
Definition Shader.cpp:1257
static RENDERCORE_API TMap< FHashedName, FShaderPipelineType * > & GetNameToTypeMap()
Definition Shader.cpp:1104
static RENDERCORE_API TLinkedList< FShaderPipelineType * > *& GetTypeList()
Definition Shader.cpp:1110
const TArray< const FShaderType * > & GetStages() const
Definition Shader.h:1960
static RENDERCORE_API TArray< const FShaderPipelineType * > GetShaderPipelineTypesByFilename(const TCHAR *Filename, bool bSearchAsRegexFilter=false)
Definition Shader.cpp:1120
bool HasPixelShader() const
Definition Shader.h:1946
const FHashedName & GetHashedName() const
Definition Shader.h:1956
bool IsMaterialTypePipeline() const
Definition Shader.h:1985
RENDERCORE_API const FSHAHash & GetSourceHash(EShaderPlatform ShaderPlatform) const
Definition Shader.cpp:1235
Definition Shader.h:2182
EFilter
Definition Shader.h:2251
@ EAll
Definition Shader.h:2252
@ EOnlyShared
Definition Shader.h:2253
@ EOnlyUnique
Definition Shader.h:2254
RENDERCORE_API void Validate(const FShaderPipelineType *InPipelineType) const
Definition Shader.cpp:1397
RENDERCORE_API void AddShader(FShader *Shader, int32 PermutationId)
Definition Shader.cpp:1364
FShaderPipeline(const FShaderPipelineType *InType)
Definition Shader.h:2185
RENDERCORE_API FShader * FindOrAddShader(FShader *Shader, int32 PermutationId)
Definition Shader.cpp:1372
LAYOUT_ARRAY(int32, PermutationIds, SF_NumGraphicsFrequencies)
FShader * GetShader(EShaderFrequency Frequency)
Definition Shader.h:2221
const FShader * GetShader(EShaderFrequency Frequency) const
Definition Shader.h:2227
ShaderType * GetShader(const FShaderMapPointerTable &InPtrTable)
Definition Shader.h:2206
RENDERCORE_API ~FShaderPipeline()
Definition Shader.cpp:1388
TArray< TShaderRef< FShader > > GetShaders(const FShaderMapBase &InShaderMap) const
Definition Shader.h:2233
LAYOUT_ARRAY(TMemoryImagePtr< FShader >, Shaders, SF_NumGraphicsFrequencies)
uint32 GetNumShaders() const
Definition Shader.h:2191
LAYOUT_FIELD(FHashedName, TypeName)
Definition Shader.h:177
LAYOUT_FIELD(uint16, BaseIndex)
LAYOUT_FIELD(uint8, BufferIndex)
bool operator<(const FShaderResourceParameterInfo &Rhs) const
Definition Shader.h:209
friend FArchive & operator<<(FArchive &Ar, FShaderResourceParameterInfo &Info)
Definition Shader.h:194
bool operator==(const FShaderResourceParameterInfo &Rhs) const
Definition Shader.h:202
FShaderResourceParameterInfo(uint16 InBaseIndex, uint8 InBufferIndex, EShaderParameterType InType)
Definition Shader.h:186
LAYOUT_FIELD(EShaderParameterType, Type)
Definition Shader.h:2040
bool operator!=(const FShaderTypeDependency &Reference) const
Definition Shader.h:2078
RENDERCORE_API void RefreshCachedSourceHash(EShaderPlatform ShaderPlatform)
Definition Shader.cpp:1275
LAYOUT_FIELD(int32, PermutationId)
LAYOUT_FIELD(FSHAHash, SourceHash)
friend FArchive & operator<<(FArchive &Ar, class FShaderTypeDependency &Ref)
Definition Shader.h:2058
LAYOUT_FIELD(FHashedName, ShaderTypeName)
FShaderTypeDependency(FShaderType *InShaderType, EShaderPlatform ShaderPlatform)
Definition Shader.h:2048
FShaderTypeDependency()
Definition Shader.h:2044
bool operator==(const FShaderTypeDependency &Reference) const
Definition Shader.h:2073
Definition Shader.h:1589
FShaderTypeRegistration(TFunctionRef< FShaderType &()> LazyShaderTypeAccessor)
Definition Shader.h:1591
static RENDERCORE_API void CommitAll()
Definition Shader.cpp:327
static RENDERCORE_API bool AreShaderTypesInitialized()
Definition Shader.cpp:337
static RENDERCORE_API TArray< const FShaderTypeRegistration * > & GetInstances()
Definition Shader.cpp:318
Definition Shader.h:1252
virtual ~FParameters()
Definition Shader.h:1254
Definition Shader.h:1238
static RENDERCORE_API TArray< const FShaderType * > GetShaderTypesByFilename(const TCHAR *Filename, bool bSearchAsRegexFilter=false)
Definition Shader.cpp:362
static RENDERCORE_API TLinkedList< FShaderType * > *& GetTypeList()
Definition Shader.cpp:342
FGlobalShaderType * GetGlobalShaderType()
Definition Shader.h:1363
static RENDERCORE_API TMap< FHashedName, FShaderType * > & GetNameToTypeMap()
Definition Shader.cpp:399
const FShaderParametersMetadata * GetRootParametersMetadata() const
Definition Shader.h:1505
const FHashedName & GetHashedShaderFilename() const
Definition Shader.h:1480
EShaderTypeForDynamicCast GetTypeForDynamicCast() const
Definition Shader.h:1450
const FName & GetFName() const
Definition Shader.h:1468
EShaderFrequency GetFrequency() const
Definition Shader.h:1460
const TCHAR * GetName() const
Definition Shader.h:1464
const FMaterialShaderType * AsMaterialShaderType() const
Definition Shader.h:1426
RENDERCORE_API void DumpDebugInfo()
Definition ShaderParameters.cpp:485
const FOpenColorIOShaderType * GetOpenColorIOShaderType() const
Definition Shader.h:1395
static RENDERCORE_API TArray< const FShaderType * > GetShaderTypesByFilenameFilter(const TFunction< bool(const TCHAR *)> &InFilenameFilter)
Definition Shader.cpp:385
friend uint32 GetTypeHash(FShaderType *Ref)
Definition Shader.h:1357
static RENDERCORE_API const TArray< FShaderType * > & GetSortedTypes(EShaderTypeForDynamicCast Type)
Definition Shader.cpp:405
int32 GetPermutationCount() const
Definition Shader.h:1499
RENDERCORE_API const FSHAHash & GetSourceHash(EShaderPlatform ShaderPlatform) const
Definition Shader.cpp:586
const FTypeLayoutDesc & GetLayout() const
Definition Shader.h:1456
RENDERCORE_API const FShaderBindingLayout * GetShaderBindingLayout(const FShaderPermutationParameters &Parameters) const
Definition Shader.cpp:472
const FMeshMaterialShaderType * GetMeshMaterialShaderType() const
Definition Shader.h:1383
FMeshMaterialShaderType * GetMeshMaterialShaderType()
Definition Shader.h:1379
const FGlobalShaderType * AsGlobalShaderType() const
Definition Shader.h:1420
static RENDERCORE_API void Uninitialize()
const TCHAR * GetFunctionName() const
Definition Shader.h:1484
const FComputeKernelShaderType * GetComputeKernelShaderType() const
Definition Shader.h:1403
const FNiagaraShaderType * AsNiagaraShaderType() const
Definition Shader.h:1438
RENDERCORE_API FShader * ConstructForDeserialization() const
Definition Shader.cpp:442
bool(* ShouldCompilePermutationType)(const FShaderPermutationParameters &)
Definition Shader.h:1259
const FNiagaraShaderType * GetNiagaraShaderType() const
Definition Shader.h:1387
int32 GetNumShaders() const
Definition Shader.h:1493
FMaterialShaderType * GetMaterialShaderType()
Definition Shader.h:1371
const FShaderBindingLayout *(* GetShaderBindingLayoutType)(const FShaderPermutationParameters &)
Definition Shader.h:1262
virtual RENDERCORE_API ~FShaderType()
Definition Shader.cpp:305
RENDERCORE_API ERayTracingPayloadType GetRayTracingPayloadType(const int32 PermutationId) const
Definition Shader.cpp:577
FOpenColorIOShaderType * GetOpenColorIOShaderType()
Definition Shader.h:1399
class FShader *(* ConstructSerializedType)()
Definition Shader.h:1257
RENDERCORE_API bool ShouldCompilePermutation(const FShaderPermutationParameters &Parameters) const
Definition Shader.cpp:462
ERayTracingPayloadType(* GetRayTracingPayloadTypeType)(const int32 PermutationId)
Definition Shader.h:1261
RENDERCORE_API friend FArchive & operator<<(FArchive &Ar, FShaderType *&Ref)
Definition Shader.cpp:410
RENDERCORE_API FShader * ConstructCompiled(const FShader::CompiledShaderInitializerType &Initializer) const
Definition Shader.cpp:447
const FNNERuntimeIREEShaderType * GetNNERuntimeIREEShaderType() const
Definition Shader.h:1411
const FHashedName & GetHashedName() const
Definition Shader.h:1472
FNNERuntimeIREEShaderType * GetNNERuntimeIREEShaderType()
Definition Shader.h:1415
FShader *(* ConstructCompiledType)(const FShader::CompiledShaderInitializerType &Initializer)
Definition Shader.h:1258
const FOpenColorIOShaderType * AsOpenColorIOShaderType() const
Definition Shader.h:1444
EShaderPermutationPrecacheRequest(* ShouldPrecachePermutationType)(const FShaderPermutationParameters &)
Definition Shader.h:1260
friend void RENDERCORE_API DumpShaderStats(EShaderPlatform Platform, EShaderFrequency Frequency)
Definition Shader.cpp:1449
FNiagaraShaderType * GetNiagaraShaderType()
Definition Shader.h:1391
const FGlobalShaderType * GetGlobalShaderType() const
Definition Shader.h:1367
EShaderTypeForDynamicCast
Definition Shader.h:1242
const FMaterialShaderType * GetMaterialShaderType() const
Definition Shader.h:1375
const TCHAR * GetShaderFilename() const
Definition Shader.h:1476
uint32 GetTypeSize() const
Definition Shader.h:1488
FComputeKernelShaderType * GetComputeKernelShaderType()
Definition Shader.h:1407
static RENDERCORE_API FShaderType * GetShaderTypeByName(const TCHAR *Name)
Definition Shader.cpp:347
const FMeshMaterialShaderType * AsMeshMaterialShaderType() const
Definition Shader.h:1432
RENDERCORE_API EShaderPermutationPrecacheRequest ShouldPrecachePermutation(const FShaderPermutationParameters &Parameters) const
Definition Shader.cpp:467
Definition Shader.h:146
friend FArchive & operator<<(FArchive &Ar, FShaderUniformBufferParameterInfo &Info)
Definition Shader.h:159
bool operator<(const FShaderUniformBufferParameterInfo &Rhs) const
Definition Shader.h:170
bool operator==(const FShaderUniformBufferParameterInfo &Rhs) const
Definition Shader.h:165
FShaderUniformBufferParameterInfo(uint16 InBaseIndex)
Definition Shader.h:153
Definition ShaderParameters.h:109
Definition Shader.h:829
uint32 GetCodeSize() const
Definition Shader.h:907
const FShaderUniformBufferParameter & GetUniformBufferParameter(const FHashedName SearchName) const
Definition Shader.h:928
EShaderPlatform GetShaderPlatform() const
Definition Shader.h:894
void SetNumInstructions(uint32 Value)
Definition Shader.h:908
LAYOUT_FIELD_EDITORONLY(FSHAHash, OutputHash)
FShaderType * GetTypeUnfrozen() const
Definition Shader.h:892
LAYOUT_FIELD(TMemoryImageArray< FHashedName >, UniformBufferParameterStructs)
static EShaderCompileJobPriority GetOverrideJobPriority()
Definition Shader.h:870
const FShaderTarget GetTarget() const
Definition Shader.h:896
static ERayTracingPayloadType GetRayTracingPayloadType(const int32 PermutationId)
Definition Shader.h:873
static void ModifyCompilationEnvironment(const FShaderPermutationParameters &, FShaderCompilerEnvironment &)
Definition Shader.h:854
uint32 GetNumTextureSamplers() const
Definition Shader.h:906
RENDERCORE_API FShader()
Definition Shader.cpp:737
FShaderType * GetType(const FPointerTableBase *InPointerTable) const
Definition Shader.h:889
static const FShaderParametersMetadata * GetRootParametersMetadata()
Definition Shader.h:965
FVertexFactoryType * GetVertexFactoryType(const FShaderMapPointerTable &InPointerTable) const
Definition Shader.h:890
RENDERCORE_API ~FShader()
Definition Shader.cpp:800
LAYOUT_FIELD_EDITORONLY(FSHAHash, SourceHash)
friend class FShaderType
Definition Shader.h:830
LAYOUT_FIELD(FShaderParameterBindings, Bindings)
uint32 GetSortKey() const
Definition Shader.h:883
LAYOUT_FIELD_EDITORONLY(FSHAHash, VFSourceHash)
static const FShaderBindingLayout * GetShaderBindingLayout(const FShaderPermutationParameters &)
Definition Shader.h:857
const TShaderUniformBufferParameter< UniformBufferStructType > & GetUniformBufferParameter() const
Definition Shader.h:913
LAYOUT_FIELD(TMemoryImageArray< FShaderUniformBufferParameter >, UniformBufferParameters)
RENDERCORE_API const FSHAHash & GetHash() const
Definition Shader.cpp:946
int32 GetResourceIndex() const
Definition Shader.h:893
EShaderFrequency GetFrequency() const
Definition Shader.h:895
const FShaderUniformBufferParameter & GetUniformBufferParameter(const FShaderParametersMetadata *SearchStruct) const
Definition Shader.h:920
RENDERCORE_API const FSHAHash & GetVertexFactoryHash() const
Definition Shader.cpp:955
static EShaderPermutationPrecacheRequest ShouldPrecachePermutation(const FShaderPermutationParameters &Parameters)
Definition Shader.h:863
RENDERCORE_API void DumpDebugInfo(const FShaderMapPointerTable &InPtrTable)
Definition Shader.cpp:985
FVertexFactoryType * GetVertexFactoryType(const FPointerTableBase *InPointerTable) const
Definition Shader.h:891
static bool ValidateCompiledResult(EShaderPlatform InPlatform, const FShaderParameterMap &InParameterMap, TArray< FString > &OutError)
Definition Shader.h:866
LAYOUT_FIELD(FShaderParameterMapInfo, ParameterMapInfo)
bool IsFrozen() const
Definition Shader.h:897
FShaderType * GetType(const FShaderMapPointerTable &InPointerTable) const
Definition Shader.h:888
RENDERCORE_API const FSHAHash & GetOutputHash() const
Definition Shader.cpp:937
uint32 GetNumInstructions() const
Definition Shader.h:905
RENDERCORE_API const FShaderParametersMetadata * FindAutomaticallyBoundUniformBufferStruct(int32 BaseIndex) const
Definition Shader.cpp:971
static bool ShouldCompilePermutation(const FShaderPermutationParameters &)
Definition Shader.h:860
Definition RefCounting.h:283
Definition VertexFactory.h:314
Definition ArrayView.h:139
Definition Array.h:670
Definition Shader.h:126
bool operator()(const TShaderTypePermutation< MetaShaderType > &A, const TShaderTypePermutation< MetaShaderType > &B) const
Definition Shader.h:128
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition HashTable.h:467
Definition MemoryImage.h:1062
Definition List.h:285
Definition UnrealString.h.inl:34
Definition MemoryImage.h:382
Definition Shader.h:2649
TOptionalShaderMapRef(const typename ShaderType::ShaderMapType *ShaderIndex)
Definition Shader.h:2651
Definition MemoryImage.h:1039
Definition RefCounting.h:454
Definition Shader.h:2629
TShaderMapRef(const typename ShaderType::ShaderMapType *ShaderIndex, const typename ShaderType::FPermutationDomain &PermutationVector)
Definition Shader.h:2639
TShaderMapRef(const typename ShaderType::ShaderMapType *ShaderIndex)
Definition Shader.h:2631
Definition Shader.h:2580
virtual const FTypeLayoutDesc & GetContentTypeDesc() const final override
Definition Shader.h:2596
const ContentType * GetContent() const
Definition Shader.h:2583
ContentType * GetMutableContent()
Definition Shader.h:2584
virtual FShaderMapPointerTable * CreatePointerTable() const final override
Definition Shader.h:2597
void FinalizeContent()
Definition Shader.h:2586
const PointerTableType & GetPointerTable() const
Definition Shader.h:2582
Definition Shader.h:1021
TShaderRefBase & operator=(const TShaderRefBase &)=default
friend bool operator==(const TShaderRefBase &Lhs, const TShaderRefBase< ShaderType1, PointerTableType > &Rhs)
Definition Shader.h:1201
FShaderType * GetType() const
Definition Shader.h:1060
const FShaderMapBase & GetShaderMapChecked() const
Definition Shader.h:1059
FShaderMapResource * GetResource() const
Definition Shader.h:2608
static TShaderRefBase< ShaderType, PointerTableType > ReinterpretCast(const TShaderRefBase< OtherShaderType, OtherPointerTableType > &Rhs)
Definition Shader.h:1047
TShaderRefBase()
Definition Shader.h:1023
const PointerTableType & GetPointerTable() const
Definition Shader.h:2601
FRHIVertexShader * GetVertexShader(bool bRequired=true) const
Definition Shader.h:1103
void Reset()
Definition Shader.h:1055
FRHIGraphicsShader * GetGraphicsShader(bool bRequired=true) const
Definition Shader.h:1085
FRHIGeometryShader * GetGeometryShader() const
Definition Shader.h:1123
FShaderMapResource & GetResourceChecked() const
Definition Shader.h:1062
FRHIPixelShader * GetPixelShader(bool bRequired=true) const
Definition Shader.h:1118
friend bool operator!=(const TShaderRefBase &Lhs, const TShaderRefBase< ShaderType1, PointerTableType > &Rhs)
Definition Shader.h:1212
TShaderRefBase & operator=(const TShaderRefBase< OtherShaderType, OtherPointerTableType > &Rhs)
Definition Shader.h:1033
ShaderType * GetShader() const
Definition Shader.h:1057
bool IsNull() const
Definition Shader.h:1053
static TShaderRefBase< ShaderType, PointerTableType > Cast(const TShaderRefBase< OtherShaderType, OtherPointerTableType > &Rhs)
Definition Shader.h:1041
const FShaderMapBase * GetShaderMap() const
Definition Shader.h:1058
bool IsValid() const
Definition Shader.h:1052
FRHIWorkGraphShader * GetWorkGraphShader() const
Definition Shader.h:1133
FRHIShader * GetRHIShaderBase(EShaderFrequency Frequency, bool bRequired=true) const
Definition Shader.h:1068
TShaderRefBase(const TShaderRefBase &)=default
TShaderRefBase(ShaderType *InShader, const FShaderMapBase &InShaderMap)
Definition Shader.h:1024
ShaderType * operator->() const
Definition Shader.h:1066
FRHIAmplificationShader * GetAmplificationShader() const
Definition Shader.h:1113
TShaderRefBase(const TShaderRefBase< OtherShaderType, OtherPointerTableType > &Rhs)
Definition Shader.h:1028
FRHIComputeShader * GetComputeShader() const
Definition Shader.h:1128
FVertexFactoryType * GetVertexFactoryType() const
Definition Shader.h:1061
FRHIMeshShader * GetMeshShader() const
Definition Shader.h:1108
Definition ShaderParameters.h:148
Definition UniquePtr.h:107
auto BinarySearchBy(const RangeType &Range, const ValueType &Value, ProjectionType Projection, SortPredicateType SortPredicate) -> decltype(GetNum(Range))
Definition BinarySearch.h:203
Definition FieldSystemNoiseAlgo.cpp:6
Definition Array.h:3955
UE_NODEBUG void IntrinsicToString(const TArray< T, AllocatorType > &Object, const FTypeLayoutDesc &TypeDesc, const FPlatformTypeLayoutParameters &LayoutParams, FMemoryToStringContext &OutContext)
Definition Array.h:3983
U16 Index
Definition radfft.cpp:71
Definition NameTypes.h:558
Definition MemoryLayout.h:51
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
Definition MemoryLayout.h:799
FRegisterRayTracingPayloadTypeHelper(ERayTracingPayloadType PayloadType, uint32 PayloadSize, TRaytracingPayloadSizeFunction PayloadSizeFunction)
Definition Shader.h:324
CORE_API static const FGuid GUID
Definition RenderingObjectVersion.h:148
@ ShaderPermutationId
Definition RenderingObjectVersion.h:73
Definition ShaderCompilerJobTypes.h:308
Definition Shader.h:1610
TArray< FGenericShaderStat > ShaderStatistics
Definition Shader.h:1624
const FShaderType::FParameters * Parameters
Definition Shader.h:1612
FShaderTarget Target
Definition Shader.h:1613
FSHAHash MaterialShaderMapHash
Definition Shader.h:1617
uint32 NumTextureSamplers
Definition Shader.h:1621
uint32 NumInstructions
Definition Shader.h:1620
const FShaderParameterMap & ParameterMap
Definition Shader.h:1615
const FSHAHash & OutputHash
Definition Shader.h:1616
const FShaderPipelineType * ShaderPipeline
Definition Shader.h:1618
int32 PermutationId
Definition Shader.h:1623
uint32 CodeSize
Definition Shader.h:1622
TConstArrayView< uint8 > Code
Definition Shader.h:1614
const FVertexFactoryType * VertexFactoryType
Definition Shader.h:1619
const FShaderType * Type
Definition Shader.h:1611
Definition ShaderCore.h:544
Definition ShaderCompilerCore.h:491
FHashedName operator()(const FShaderPipeline *InShaderPipeline)
Definition Shader.h:2317
LAYOUT_FIELD(EUniformBufferBaseType, BaseType)
DECLARE_INLINE_TYPE_LAYOUT(FBindlessResourceParameter, NonVirtual)
DECLARE_INLINE_TYPE_LAYOUT(FParameterStructReference, NonVirtual)
DECLARE_INLINE_TYPE_LAYOUT(FParameter, NonVirtual)
LAYOUT_FIELD(EUniformBufferBaseType, BaseType)
DECLARE_INLINE_TYPE_LAYOUT(FResourceParameter, NonVirtual)
Definition ShaderPermutation.h:27
Definition ShaderSerialization.h:26
Definition ShaderCore.h:186
Definition ShaderCodeLibrary.h:118
Definition MemoryLayout.h:108
static int32 Strlen(const CharType *String)
Definition CString.h:1047
static UE_FORCEINLINE_HINT int32 Strncmp(const CharType *String1, const CharType *String2, SIZE_T Count)
Definition CString.h:1024
Definition MemoryImage.h:71
uint32 FrozenSize
Definition MemoryImage.h:102
T * Object
Definition MemoryImage.h:101
Definition ShaderPermutation.h:229
Definition Shader.h:93
bool operator==(const TShaderTypePermutation &Other) const
Definition Shader.h:103
TShaderTypePermutation(MetaShaderType *InType, int32 InPermutationId)
Definition Shader.h:97
friend uint32 GetTypeHash(const TShaderTypePermutation &Var)
Definition Shader.h:113
bool operator!=(const TShaderTypePermutation &Other) const
Definition Shader.h:108
MetaShaderType *const Type
Definition Shader.h:94
const int32 PermutationId
Definition Shader.h:95