UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ShaderCodeArchive.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Containers/Array.h"
7#include "Containers/HashTable.h"
8#include "Containers/Map.h"
9#include "Containers/Set.h"
11#include "CoreMinimal.h"
12#include "FileCache/FileCache.h"
13#include "HAL/CriticalSection.h"
14#include "HAL/Platform.h"
15#include "IO/IoDispatcher.h"
17#include "Misc/CoreDelegates.h"
19#include "Misc/SecureHash.h"
20#include "RHI.h"
21#include "RHIDefinitions.h"
23#include "Shader.h"
24#include "ShaderCodeLibrary.h"
26#include "UObject/NameTypes.h"
27
28#if WITH_EDITOR
29class FCbFieldView;
30class FCbWriter;
31#endif
32
33#ifndef USE_MMAPPED_SHADERARCHIVE
34 // If enabled FSerializedShaderArchive will use a mmapping of the on-disk shader archive instead of normal serialization. The on-disk format must match the expected in memory layout.
35 #define USE_MMAPPED_SHADERARCHIVE 0
36#endif
37
38// enable visualization in the desktop Development builds only as it has a memory hit and writes files
39#define UE_SCA_VISUALIZE_SHADER_USAGE (!WITH_EDITOR && UE_BUILD_DEVELOPMENT && PLATFORM_DESKTOP)
40
41// enable deep, manual debugging of leaked preload groups. This level of information slows the engine down and is only needed when chasing tricky bugs
42#define UE_SCA_DEBUG_PRELOADING (0)
43
45{
50
52 {
53 return Ar << Ref.ShaderIndicesOffset << Ref.NumShaders << Ref.FirstPreloadIndex << Ref.NumPreloadEntries;
54 }
55};
56
57static FArchive& operator <<(FArchive& Ar, FFileCachePreloadEntry& Ref)
58{
59 return Ar << Ref.Offset << Ref.Size;
60}
61
62
63#if USE_MMAPPED_SHADERARCHIVE
64#pragma pack(push, 1)
65#endif
67{
72
77
79 {
80 return Ar << Ref.Offset << Ref.Size << Ref.UncompressedSize << Ref.Frequency;
81 }
82};
83#if USE_MMAPPED_SHADERARCHIVE
84#pragma pack(pop)
85#endif
86
87// Portion of shader code archive that's serialize to disk
89{
90public:
91#if USE_MMAPPED_SHADERARCHIVE
92 template<typename T> using TArrayType = TArrayView<T>;
93 // Ensure use of the const Get functions when mmapping is used.
94 private:
95#else
96 template<typename T> using TArrayType = TArray<T>;
97#endif
98
101
104
107
113
118
119public:
126
129
130#if WITH_EDITOR
133
134 struct FShaderTypeHashes
135 {
136 TArray<uint64> Data;
137
139 {
140 Ar << Ref.Data;
141 return Ar;
142 }
143 };
144
146 TArray<FShaderTypeHashes> ShaderTypes;
147
148 enum class EAssetInfoVersion : uint8
149 {
150 CurrentVersion = 2
151 };
152
153 struct FDebugStats
154 {
155 int32 NumAssets;
158 int32 NumShaders;
161 };
162
164 {
166 FString TextualRepresentation;
167
170
173
176
179
182
185
188 };
189#endif
190
194
196 {
197#if USE_MMAPPED_SHADERARCHIVE
198 return ShaderHashes.Num() * ShaderHashes.GetTypeSize() +
199 ShaderEntries.Num() * ShaderEntries.GetTypeSize() +
200 ShaderMapHashes.Num() * ShaderMapHashes.GetTypeSize() +
201 ShaderMapEntries.Num() * ShaderMapEntries.GetTypeSize() +
202 PreloadEntries.Num() * PreloadEntries.GetTypeSize() +
203 ShaderIndices.Num() * ShaderIndices.GetTypeSize()
204#else
205 return ShaderHashes.GetAllocatedSize() +
206 ShaderEntries.GetAllocatedSize() +
207 ShaderMapHashes.GetAllocatedSize() +
208 ShaderMapEntries.GetAllocatedSize() +
209 PreloadEntries.GetAllocatedSize() +
210 ShaderIndices.GetAllocatedSize()
211#endif
212#if WITH_EDITOR
213 + ShaderCodeToAssets.GetAllocatedSize()
214 + ShaderTypes.GetAllocatedSize()
215#endif // WITH_EDITOR
216 ;
217 }
218
219 void Empty()
220 {
222#if !USE_MMAPPED_SHADERARCHIVE
223 ShaderHashes.Empty();
224 ShaderEntries.Empty();
225#endif
227#if WITH_EDITOR
228 ShaderTypes.Empty();
229#endif
230 }
231
233 {
234#if !USE_MMAPPED_SHADERARCHIVE
235 ShaderMapHashes.Empty();
236 ShaderMapEntries.Empty();
237 PreloadEntries.Empty();
238 ShaderIndices.Empty();
239#endif
241#if WITH_EDITOR
242 ShaderCodeToAssets.Empty();
243#endif
244 }
245
247 {
248 return ShaderMapEntries.Num();
249 }
250
252 {
253 return ShaderEntries.Num();
254 }
255
256 bool IsEmpty() const
257 {
258 return ShaderMapEntries.IsEmpty() && ShaderEntries.IsEmpty() && PreloadEntries.IsEmpty()
259#if WITH_EDITOR
260 && ShaderCodeToAssets.IsEmpty()
261 && ShaderTypes.IsEmpty()
262#endif
263 ;
264 }
265
270
271#if !USE_MMAPPED_SHADERARCHIVE
272 RENDERCORE_API bool FindOrAddShader(const FSHAHash& Hash, int32& OutIndex);
276#endif
277
279
281#if WITH_EDITOR
283 RENDERCORE_API bool LoadAssetInfo(const FString& Filename);
287 RENDERCORE_API void DumpContentsInPlaintext(FString& OutText) const;
290#endif
291
293 {
294 Ref.Serialize(Ar);
295 return Ar;
296 }
297};
298
299// run-time only debugging facility
301{
302#if UE_SCA_VISUALIZE_SHADER_USAGE
305
307 int32 NumShaders;
308
311
314
317
320
321 void Initialize(const int32 InNumShaders);
322
323 inline void MarkExplicitlyPreloadedForVisualization(int32 ShaderIndex)
324 {
327 {
329 ExplicitlyPreloadedShaders.Add(ShaderIndex);
330 }
331 }
332
333 inline void MarkPreloadedForVisualization(int32 ShaderIndex)
334 {
337 {
339 PreloadedShaders.Add(ShaderIndex);
340 }
341 }
342
343 inline void MarkDecompressedForVisualization(int32 ShaderIndex)
344 {
347 {
349 DecompressedShaders.Add(ShaderIndex);
350 }
351 }
352
353 inline void MarkCreatedForVisualization(int32 ShaderIndex)
354 {
357 {
359 CreatedShaders.Add(ShaderIndex);
360 }
361 }
362
363 void SaveShaderUsageBitmap(const FString& Name, EShaderPlatform ShaderPlatform);
364#else
365 inline void Initialize(const int32 InNumShaders) {}
366 inline void MarkPreloadedForVisualization(int32 ShaderIndex) {}
368 inline void MarkDecompressedForVisualization(int32 ShaderIndex) {}
369 inline void MarkCreatedForVisualization(int32 ShaderIndex) {}
370 inline void SaveShaderUsageBitmap(const FString& Name, EShaderPlatform ShaderPlatform) {}
371#endif // UE_SCA_VISUALIZE_SHADER_USAGE
372};
373
375{
376public:
377 static FShaderCodeArchive* Create(EShaderPlatform InPlatform, FArchive& Ar, const FString& InDestFilePath, const FString& InLibraryDir, const FString& InLibraryName);
378
379 virtual ~FShaderCodeArchive();
380
381 virtual bool IsNativeLibrary() const override { return false; }
382
383 virtual uint32 GetSizeBytes() const override
384 {
385 return sizeof(*this) +
387 ShaderPreloads.GetAllocatedSize();
388 }
389
390 virtual int32 GetNumShaders() const override { return SerializedShaders.GetShaderEntries().Num(); }
391 virtual int32 GetNumShaderMaps() const override { return SerializedShaders.GetShaderMapEntries().Num(); }
392 virtual int32 GetNumShadersForShaderMap(int32 ShaderMapIndex) const override { return SerializedShaders.GetShaderMapEntries()[ShaderMapIndex].NumShaders; }
393
394 virtual int32 GetShaderIndex(int32 ShaderMapIndex, int32 i) const override
395 {
397 return SerializedShaders.GetShaderIndices()[ShaderMapEntry.ShaderIndicesOffset + i];
398 }
399
400 virtual void GetAllShaderIndices(int32 ShaderMapIndex, TArray<int32>& ShaderIndices)
401 {
403 for (uint32 i = 0u; i < ShaderMapEntry.NumShaders; ++i)
404 {
405 ShaderIndices.AddUnique(ShaderIndices[ShaderMapEntry.ShaderIndicesOffset + i]);
406 }
407 }
408
409 virtual int32 FindShaderMapIndex(const FSHAHash& Hash) override
410 {
412 }
413
414 virtual int32 FindShaderIndex(const FSHAHash& Hash) override
415 {
417 }
418
419 virtual FSHAHash GetShaderHash(int32 ShaderMapIndex, int32 ShaderIndex) override
420 {
421 return SerializedShaders.GetShaderHashes()[GetShaderIndex(ShaderMapIndex, ShaderIndex)];
422 };
423
424 virtual FSHAHash GetShaderMapHash(int32 ShaderMapIndex) const override
425 {
426 return SerializedShaders.GetShaderMapHashes()[ShaderMapIndex];
427 };
428
429 virtual bool PreloadShader(int32 ShaderIndex, FGraphEventArray& OutCompletionEvents) override;
430
431 virtual bool PreloadShaderMap(int32 ShaderMapIndex, FGraphEventArray& OutCompletionEvents) override;
432
433 virtual void ReleasePreloadedShader(int32 ShaderIndex) override;
434
435 virtual TRefCountPtr<FRHIShader> CreateShader(int32 Index, bool bRequired = true) override;
436 virtual void Teardown() override;
437
438 void OnShaderPreloadFinished(int32 ShaderIndex, const IMemoryReadStreamRef& PreloadData);
439
440protected:
442
446
461
462 bool WaitForPreload(FShaderPreloadEntry& ShaderPreloadEntry);
463
464 // Library directory
465 FString LibraryDir;
466
467 // Offset at where shader code starts in a code library
469
470 // Library file handle for async reads
472
473 // The shader code present in the library
475
478
481};
482
483
484
486{
491
492 // We decompression, group, and recompress shaders when they are added to iostore containers in UnrealPak, where we don't have access to cvars - so there's no way
493 // to configure - so we force Oodle and allow specification of the parameters here.
495}
496
499{
504
506 {
507 return Ar << Ref.ShaderIndicesOffset << Ref.NumShaders;
508 }
509};
510
513{
514 union
515 {
517 struct
518 {
520 uint64 Frequency : SF_NumBits; // 4 as of now
521
524
527 };
528 };
529
531 : Packed(0)
532 {
533 }
534
536 {
538 }
539
541 {
542 return Ar << Ref.Packed;
543 }
544};
545
546static_assert(sizeof(FIoStoreShaderCodeEntry) == sizeof(uint64), "To reduce memory footprint, shader code entries should be as small as possible");
547
550{
555
560
562 {
563 return Ar << Ref.ShaderIndicesOffset << Ref.NumShaders << Ref.UncompressedSize << Ref.CompressedSize;
564 }
565
567 inline bool IsGroupCompressed() const
568 {
570 }
571};
572
574{
575public:
576
579
582
585
588
591
594
600
602
603 inline uint64 GetShaderUncompressedSize(int ShaderIndex) const
604 {
607
608 for (uint32 ShaderIdxIdx = GroupEntry.ShaderIndicesOffset, StopBeforeIdxIdx = GroupEntry.ShaderIndicesOffset + GroupEntry.NumShaders; ShaderIdxIdx < StopBeforeIdxIdx; ++ShaderIdxIdx)
609 {
611 if (ShaderIndex == GroupMemberShaderIndex)
612 {
613 // found ourselves, now find our size by subtracting from the next neighbor or the group size
615 {
617 return NextShaderEntry.UncompressedOffsetInGroup - ThisShaderEntry.UncompressedOffsetInGroup;
618 }
619 else
620 {
621 return GroupEntry.UncompressedSize - ThisShaderEntry.UncompressedOffsetInGroup;
622 }
623 }
624 }
625
626 checkf(false, TEXT("Could not find shader index %d in its own group %" UINT64_FMT " - library is corrupted."), ShaderIndex, ThisShaderEntry.ShaderGroupIndex);
627 return 0;
628 }
629
641};
642
644{
645public:
646 RENDERCORE_API static FIoChunkId GetShaderCodeArchiveChunkId(const FString& LibraryName, FName FormatName);
647 RENDERCORE_API static FIoChunkId GetShaderCodeChunkId(const FSHAHash& ShaderHash);
652
654
655 virtual bool IsNativeLibrary() const override { return false; }
656
657 virtual uint32 GetSizeBytes() const override
658 {
659 return sizeof(*this) +
660 Header.GetAllocatedSize() +
661 PreloadedShaderGroups.GetAllocatedSize();
662 }
663
664 virtual uint32 GetShaderSizeBytes(int32 ShaderIndex) const override;
665
666 virtual int32 GetNumShaders() const override { return Header.ShaderEntries.Num(); }
667 virtual int32 GetNumShaderMaps() const override { return Header.ShaderMapEntries.Num(); }
668 virtual int32 GetNumShadersForShaderMap(int32 ShaderMapIndex) const override { return Header.ShaderMapEntries[ShaderMapIndex].NumShaders; }
669
670 virtual int32 GetShaderIndex(int32 ShaderMapIndex, int32 i) const override
671 {
672 const FIoStoreShaderMapEntry& ShaderMapEntry = Header.ShaderMapEntries[ShaderMapIndex];
673 return Header.ShaderIndices[ShaderMapEntry.ShaderIndicesOffset + i];
674 }
675
676 virtual void GetAllShaderIndices(int32 ShaderMapIndex, TArray<int32>& ShaderIndices)
677 {
678 const FIoStoreShaderMapEntry& ShaderMapEntry = Header.ShaderMapEntries[ShaderMapIndex];
679 for (uint32 i = 0u; i < ShaderMapEntry.NumShaders; ++i)
680 {
681 ShaderIndices.AddUnique(Header.ShaderIndices[ShaderMapEntry.ShaderIndicesOffset + i]);
682 }
683 }
684
685 virtual int32 FindShaderMapIndex(const FSHAHash& Hash) override;
686 virtual int32 FindShaderIndex(const FSHAHash& Hash) override;
687 virtual FSHAHash GetShaderHash(int32 ShaderMapIndex, int32 ShaderIndex) override
688 {
689 return Header.ShaderHashes[GetShaderIndex(ShaderMapIndex, ShaderIndex)];
690 }
691
692 virtual FSHAHash GetShaderMapHash(int32 ShaderMapIndex) const override
693 {
694 return Header.ShaderMapHashes[ShaderMapIndex];
695 }
696
697 virtual bool IsPreloading(int32 ShaderIndex, FGraphEventArray& OutCompletionEvents) override;
698 virtual bool PreloadShader(int32 ShaderIndex, FGraphEventArray& OutCompletionEvents) override;
699 virtual void AddRefPreloadedShaderGroup(int32 ShaderGroupIndex) override;
700 virtual void ReleasePreloadedShaderGroup(int32 ShaderGroupIndex) override;
701
703 virtual int32 GetGroupIndexForShader(int32 ShaderIndex) const override
704 {
705 return Header.ShaderEntries[ShaderIndex].ShaderGroupIndex;
706 }
707
708 virtual bool PreloadShaderMap(int32 ShaderMapIndex, FGraphEventArray& OutCompletionEvents) override;
710 virtual void ReleasePreloadedShader(int32 ShaderIndex) override;
711 virtual TRefCountPtr<FRHIShader> CreateShader(int32 Index, bool bRequired = true) override;
712 virtual void Teardown() override;
713
714private:
715 static constexpr uint32 CurrentVersion = 1;
716
717 struct FShaderGroupPreloadEntry
718 {
719 FGraphEventRef PreloadEvent;
720 FIoRequest IoRequest;
721 uint32 FramePreloadStarted = ~0u;
722 uint32 NumRefs : 31;
723 uint32 bNeverToBePreloaded : 1;
724
725#if UE_SCA_DEBUG_PRELOADING
726 FString DebugInfo;
727#endif
728
729 FShaderGroupPreloadEntry()
730 : NumRefs(0)
731 , bNeverToBePreloaded(0)
732 {
733 }
734
735 ~FShaderGroupPreloadEntry()
736 {
737 }
738 };
739
741
742 FIoDispatcher& IoDispatcher;
743
745 bool PreloadShaderGroup(int32 ShaderGroupIndex, FGraphEventArray& OutCompletionEvents,
747 const FString& CallsiteInfo,
748#endif
750
752 void SetupPreloadEntryForLoading(int32 ShaderGroupIndex, FShaderGroupPreloadEntry& PreloadEntry);
753
755 void MarkPreloadEntrySkipped(int32 ShaderGroupIndex
757 , const FString& CallsiteInfo
758#endif
759 );
760
762 void ReleasePreloadEntry(int32 ShaderGroupIndex
764 , const FString& CallsiteInfo
765#endif
766 );
767
769 inline FShaderGroupPreloadEntry* FindOrAddPreloadEntry(int32 ShaderGroupIndex)
770 {
771 FShaderGroupPreloadEntry*& Ptr = PreloadedShaderGroups.FindOrAdd(ShaderGroupIndex);
772 if (UNLIKELY(Ptr == nullptr))
773 {
774 Ptr = new FShaderGroupPreloadEntry;
775 }
776 return Ptr;
777 }
778
780 inline FShaderGroupPreloadEntry* FindExistingPreloadEntry(int32 ShaderGroupIndex)
781 {
782 FShaderGroupPreloadEntry** PtrPtr = PreloadedShaderGroups.Find(ShaderGroupIndex);
783 checkf(PtrPtr != nullptr, TEXT("The preload entry for a shader group we assumed to exist does not exist!"));
784 return *PtrPtr;
785 }
786
788 bool GroupOnlyContainsRaytracingShaders(int32 ShaderGroupIndex);
789
792
794 FHashTable ShaderMapHashTable;
795 FHashTable ShaderHashTable;
796
798 TMap<int32, FShaderGroupPreloadEntry*> PreloadedShaderGroups;
800 FRWLock PreloadedShaderGroupsLock;
801
803 FShaderUsageVisualizer DebugVisualizer;
804};
#define UINT64_FMT
Definition AndroidPlatformString.h:66
#define FORCENOINLINE
Definition AndroidPlatform.h:142
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
bool LoadFromCompactBinary(FCbFieldView Field, FAssetDependency &Dependency)
Definition AssetRegistry.cpp:10420
#define LIKELY(x)
Definition CityHash.cpp:107
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
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
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
EShaderFrequency
Definition RHIDefinitions.h:202
@ SF_NumFrequencies
Definition RHIDefinitions.h:216
@ SF_NumBits
Definition RHIDefinitions.h:224
EShaderPlatform
Definition RHIShaderPlatform.h:11
int32 GShaderCodeLibraryVisualizeShaderUsage
Definition ShaderCodeArchive.cpp:55
#define UE_SCA_DEBUG_PRELOADING
Definition ShaderCodeArchive.h:42
TSet< FName > FShaderMapAssetPaths
Definition Shader.h:88
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition CompactBinary.h:610
Definition CompactBinaryWriter.h:68
Definition HashTable.h:210
void Clear()
Definition HashTable.h:350
Definition IoChunkId.h:64
Definition IoDispatcher.h:350
Definition IoDispatcher.h:237
Definition ShaderCodeArchive.h:644
virtual bool IsPreloading(int32 ShaderIndex, FGraphEventArray &OutCompletionEvents) override
Definition ShaderCodeArchive.cpp:2172
virtual int32 GetNumShadersForShaderMap(int32 ShaderMapIndex) const override
Definition ShaderCodeArchive.h:668
static RENDERCORE_API FIoChunkId GetShaderCodeChunkId(const FSHAHash &ShaderHash)
Definition ShaderCodeArchive.cpp:1498
virtual TRefCountPtr< FRHIShader > CreateShader(int32 Index, bool bRequired=true) override
Definition ShaderCodeArchive.cpp:2388
virtual bool IsNativeLibrary() const override
Definition ShaderCodeArchive.h:655
virtual int32 GetShaderIndex(int32 ShaderMapIndex, int32 i) const override
Definition ShaderCodeArchive.h:670
virtual ~FIoStoreShaderCodeArchive()
Definition ShaderCodeArchive.cpp:2009
virtual FSHAHash GetShaderMapHash(int32 ShaderMapIndex) const override
Definition ShaderCodeArchive.h:692
virtual int32 GetNumShaderMaps() const override
Definition ShaderCodeArchive.h:667
virtual void Teardown() override
Definition ShaderCodeArchive.cpp:2015
static RENDERCORE_API void CreateIoStoreShaderCodeArchiveHeader(const FName &Format, const FSerializedShaderArchive &SerializedShaders, FIoStoreShaderCodeArchiveHeader &OutHeader)
Definition ShaderCodeArchive.cpp:1508
virtual int32 FindShaderIndex(const FSHAHash &Hash) override
Definition ShaderCodeArchive.cpp:2375
virtual void AddRefPreloadedShaderGroup(int32 ShaderGroupIndex) override
Definition ShaderCodeArchive.cpp:2160
virtual FSHAHash GetShaderHash(int32 ShaderMapIndex, int32 ShaderIndex) override
Definition ShaderCodeArchive.h:687
virtual void ReleasePreloadedShaderGroup(int32 ShaderGroupIndex) override
Definition ShaderCodeArchive.cpp:2167
virtual int32 FindShaderMapIndex(const FSHAHash &Hash) override
Definition ShaderCodeArchive.cpp:2362
virtual bool PreloadShaderMap(int32 ShaderMapIndex, FGraphEventArray &OutCompletionEvents) override
Definition ShaderCodeArchive.cpp:2217
virtual int32 GetGroupIndexForShader(int32 ShaderIndex) const override
Definition ShaderCodeArchive.h:703
static RENDERCORE_API void SaveIoStoreShaderCodeArchive(const FIoStoreShaderCodeArchiveHeader &Header, FArchive &OutLibraryAr)
Definition ShaderCodeArchive.cpp:1947
static RENDERCORE_API FIoChunkId GetShaderCodeArchiveChunkId(const FString &LibraryName, FName FormatName)
Definition ShaderCodeArchive.cpp:1490
virtual uint32 GetSizeBytes() const override
Definition ShaderCodeArchive.h:657
virtual uint32 GetShaderSizeBytes(int32 ShaderIndex) const override
Definition ShaderCodeArchive.cpp:2155
virtual void ReleasePreloadedShader(int32 ShaderIndex) override
Definition ShaderCodeArchive.cpp:2353
virtual void GetAllShaderIndices(int32 ShaderMapIndex, TArray< int32 > &ShaderIndices)
Definition ShaderCodeArchive.h:676
virtual int32 GetNumShaders() const override
Definition ShaderCodeArchive.h:666
Definition NameTypes.h:617
Definition RHIShaderLibrary.h:13
FString LibraryName
Definition RHIShaderLibrary.h:50
Definition SecureHash.h:226
Definition ScopeLock.h:141
Definition ShaderCodeArchive.h:89
TArrayType< FShaderCodeEntry > ShaderEntries
Definition ShaderCodeArchive.h:109
bool IsEmpty() const
Definition ShaderCodeArchive.h:256
TArrayType< uint32 > ShaderIndices
Definition ShaderCodeArchive.h:117
int32 GetNumShaderMaps() const
Definition ShaderCodeArchive.h:246
RENDERCORE_API int32 FindShader(const FSHAHash &Hash) const
Definition ShaderCodeArchive.cpp:177
const TArrayView< const FFileCachePreloadEntry > GetPreloadEntries() const
Definition ShaderCodeArchive.h:121
TArrayType< FFileCachePreloadEntry > PreloadEntries
Definition ShaderCodeArchive.h:112
const TArrayView< const FShaderCodeEntry > GetShaderEntries() const
Definition ShaderCodeArchive.h:122
RENDERCORE_API int32 FindShaderMap(const FSHAHash &Hash) const
Definition ShaderCodeArchive.cpp:133
FHashTable ShaderHashTable
Definition ShaderCodeArchive.h:128
const TArrayView< const FSHAHash > GetShaderMapHashes() const
Definition ShaderCodeArchive.h:125
RENDERCORE_API bool FindOrAddShader(const FSHAHash &Hash, int32 &OutIndex)
Definition ShaderCodeArchive.cpp:184
FSerializedShaderArchive()
Definition ShaderCodeArchive.h:191
const TArrayView< const FSHAHash > GetShaderHashes() const
Definition ShaderCodeArchive.h:124
void Empty()
Definition ShaderCodeArchive.h:219
const TArrayView< const uint32 > GetShaderIndices() const
Definition ShaderCodeArchive.h:120
void EmptyShaderMaps()
Definition ShaderCodeArchive.h:232
TArrayType< FShaderMapEntry > ShaderMapEntries
Definition ShaderCodeArchive.h:106
RENDERCORE_API void RemoveLastAddedShader()
Definition ShaderCodeArchive.cpp:204
RENDERCORE_API void Finalize()
Definition ShaderCodeArchive.cpp:535
int64 GetAllocatedSize() const
Definition ShaderCodeArchive.h:195
const TArrayView< const FShaderMapEntry > GetShaderMapEntries() const
Definition ShaderCodeArchive.h:123
RENDERCORE_API bool FindOrAddShaderMap(const FSHAHash &Hash, int32 &OutIndex, const FShaderMapAssetPaths *AssociatedAssets)
Definition ShaderCodeArchive.cpp:140
RENDERCORE_API void DecompressShader(int32 Index, const TArray< FSharedBuffer > &ShaderCode, TArray< uint8 > &OutDecompressedShader) const
Definition ShaderCodeArchive.cpp:520
FHashTable ShaderMapHashTable
Definition ShaderCodeArchive.h:127
TArrayType< FSHAHash > ShaderHashes
Definition ShaderCodeArchive.h:103
RENDERCORE_API int32 FindShaderMapWithKey(const FSHAHash &Hash, uint32 Key) const
Definition ShaderCodeArchive.cpp:121
TArrayType< FSHAHash > ShaderMapHashes
Definition ShaderCodeArchive.h:100
RENDERCORE_API int32 FindShaderWithKey(const FSHAHash &Hash, uint32 Key) const
Definition ShaderCodeArchive.cpp:165
int32 GetNumShaders() const
Definition ShaderCodeArchive.h:251
friend FArchive & operator<<(FArchive &Ar, FSerializedShaderArchive &Ref)
Definition ShaderCodeArchive.h:292
Definition ShaderCodeArchive.h:375
virtual int32 FindShaderMapIndex(const FSHAHash &Hash) override
Definition ShaderCodeArchive.h:409
virtual int32 GetNumShaderMaps() const override
Definition ShaderCodeArchive.h:391
FShaderUsageVisualizer DebugVisualizer
Definition ShaderCodeArchive.h:480
virtual bool IsNativeLibrary() const override
Definition ShaderCodeArchive.h:381
int64 LibraryCodeOffset
Definition ShaderCodeArchive.h:468
virtual ~FShaderCodeArchive()
Definition ShaderCodeArchive.cpp:1184
FString LibraryDir
Definition ShaderCodeArchive.h:465
FSerializedShaderArchive SerializedShaders
Definition ShaderCodeArchive.h:474
bool WaitForPreload(FShaderPreloadEntry &ShaderPreloadEntry)
Definition ShaderCodeArchive.cpp:1351
virtual bool PreloadShaderMap(int32 ShaderMapIndex, FGraphEventArray &OutCompletionEvents) override
Definition ShaderCodeArchive.cpp:1293
void OnShaderPreloadFinished(int32 ShaderIndex, const IMemoryReadStreamRef &PreloadData)
Definition ShaderCodeArchive.cpp:1217
virtual int32 FindShaderIndex(const FSHAHash &Hash) override
Definition ShaderCodeArchive.h:414
TArray< FShaderPreloadEntry > ShaderPreloads
Definition ShaderCodeArchive.h:476
virtual int32 GetNumShaders() const override
Definition ShaderCodeArchive.h:390
virtual int32 GetShaderIndex(int32 ShaderMapIndex, int32 i) const override
Definition ShaderCodeArchive.h:394
FORCENOINLINE void CheckShaderCreation(void *ShaderPtr, int32 Index)
Definition ShaderCodeArchive.h:443
virtual FSHAHash GetShaderMapHash(int32 ShaderMapIndex) const override
Definition ShaderCodeArchive.h:424
virtual FSHAHash GetShaderHash(int32 ShaderMapIndex, int32 ShaderIndex) override
Definition ShaderCodeArchive.h:419
virtual uint32 GetSizeBytes() const override
Definition ShaderCodeArchive.h:383
virtual void GetAllShaderIndices(int32 ShaderMapIndex, TArray< int32 > &ShaderIndices)
Definition ShaderCodeArchive.h:400
IFileCacheHandle * FileCacheHandle
Definition ShaderCodeArchive.h:471
virtual void ReleasePreloadedShader(int32 ShaderIndex) override
Definition ShaderCodeArchive.cpp:1374
FRWLock ShaderPreloadLock
Definition ShaderCodeArchive.h:477
virtual void Teardown() override
Definition ShaderCodeArchive.cpp:1190
virtual int32 GetNumShadersForShaderMap(int32 ShaderMapIndex) const override
Definition ShaderCodeArchive.h:392
virtual TRefCountPtr< FRHIShader > CreateShader(int32 Index, bool bRequired=true) override
Definition ShaderCodeArchive.cpp:1403
Definition FileCache.h:32
Definition ArrayView.h:139
UE_REWRITE bool IsEmpty() const
Definition Array.h:1133
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize(void) const
Definition Array.h:1059
UE_FORCEINLINE_HINT SizeType AddUnique(ElementType &&Item)
Definition Array.h:2993
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition RefCounting.h:454
Definition CriticalSection.h:14
ECompressor
Definition OodleDataCompression.h:49
ECompressionLevel
Definition OodleDataCompression.h:94
Definition FieldSystemNoiseAlgo.cpp:6
Definition ShaderCodeArchive.h:486
RENDERCORE_API void DecompressShaderWithOodle(uint8 *OutDecompressedShader, int64 UncompressedSize, const uint8 *CompressedShaderCode, int64 CompressedSize)
Definition ShaderCodeArchive.cpp:471
RENDERCORE_API bool CompressShaderWithOodle(uint8 *OutCompressedShader, int64 &OutCompressedSize, const uint8 *InUncompressedShaderCode, int64 InUncompressedSize, FOodleDataCompression::ECompressor InOodleCompressor, FOodleDataCompression::ECompressionLevel InOodleLevel)
Definition ShaderCodeArchive.cpp:504
@ Ref
Value is copied out after function call. Only valid on function param declaration.
Definition ObjectMacros.h:1074
U16 Index
Definition radfft.cpp:71
Definition FileCache.h:17
Definition ShaderCodeArchive.h:574
TArray< FSHAHash > ShaderHashes
Definition ShaderCodeArchive.h:581
TArray< FIoStoreShaderCodeEntry > ShaderEntries
Definition ShaderCodeArchive.h:590
TArray< FIoStoreShaderGroupEntry > ShaderGroupEntries
Definition ShaderCodeArchive.h:593
uint64 GetShaderUncompressedSize(int ShaderIndex) const
Definition ShaderCodeArchive.h:603
TArray< FIoChunkId > ShaderGroupIoHashes
Definition ShaderCodeArchive.h:584
friend RENDERCORE_API FArchive & operator<<(FArchive &Ar, FIoStoreShaderCodeArchiveHeader &Ref)
Definition ShaderCodeArchive.cpp:1935
uint64 GetAllocatedSize() const
Definition ShaderCodeArchive.h:630
TArray< FSHAHash > ShaderMapHashes
Definition ShaderCodeArchive.h:578
TArray< uint32 > ShaderIndices
Definition ShaderCodeArchive.h:599
TArray< FIoStoreShaderMapEntry > ShaderMapEntries
Definition ShaderCodeArchive.h:587
Definition ShaderCodeArchive.h:513
uint64 Frequency
Definition ShaderCodeArchive.h:520
FIoStoreShaderCodeEntry()
Definition ShaderCodeArchive.h:530
uint64 Packed
Definition ShaderCodeArchive.h:516
EShaderFrequency GetFrequency() const
Definition ShaderCodeArchive.h:535
uint64 UncompressedOffsetInGroup
Definition ShaderCodeArchive.h:526
uint64 ShaderGroupIndex
Definition ShaderCodeArchive.h:523
friend FArchive & operator<<(FArchive &Ar, FIoStoreShaderCodeEntry &Ref)
Definition ShaderCodeArchive.h:540
Definition ShaderCodeArchive.h:550
uint32 NumShaders
Definition ShaderCodeArchive.h:554
friend FArchive & operator<<(FArchive &Ar, FIoStoreShaderGroupEntry &Ref)
Definition ShaderCodeArchive.h:561
bool IsGroupCompressed() const
Definition ShaderCodeArchive.h:567
uint32 UncompressedSize
Definition ShaderCodeArchive.h:557
uint32 ShaderIndicesOffset
Definition ShaderCodeArchive.h:552
uint32 CompressedSize
Definition ShaderCodeArchive.h:559
Definition ShaderCodeArchive.h:499
uint32 NumShaders
Definition ShaderCodeArchive.h:503
uint32 ShaderIndicesOffset
Definition ShaderCodeArchive.h:501
friend FArchive & operator<<(FArchive &Ar, FIoStoreShaderMapEntry &Ref)
Definition ShaderCodeArchive.h:505
Definition ShaderCodeArchive.h:448
FShaderPreloadEntry()
Definition ShaderCodeArchive.h:455
FGraphEventRef PreloadEvent
Definition ShaderCodeArchive.h:449
uint32 FramePreloadStarted
Definition ShaderCodeArchive.h:451
void * Code
Definition ShaderCodeArchive.h:450
uint32 bNeverToBePreloaded
Definition ShaderCodeArchive.h:453
uint32 NumRefs
Definition ShaderCodeArchive.h:452
Definition ShaderCodeArchive.h:67
EShaderFrequency GetFrequency() const
Definition ShaderCodeArchive.h:73
uint32 UncompressedSize
Definition ShaderCodeArchive.h:70
uint64 Offset
Definition ShaderCodeArchive.h:68
friend FArchive & operator<<(FArchive &Ar, FShaderCodeEntry &Ref)
Definition ShaderCodeArchive.h:78
uint32 Size
Definition ShaderCodeArchive.h:69
uint8 Frequency
Definition ShaderCodeArchive.h:71
Definition ShaderCodeArchive.h:45
uint32 FirstPreloadIndex
Definition ShaderCodeArchive.h:48
uint32 ShaderIndicesOffset
Definition ShaderCodeArchive.h:46
uint32 NumPreloadEntries
Definition ShaderCodeArchive.h:49
uint32 NumShaders
Definition ShaderCodeArchive.h:47
friend FArchive & operator<<(FArchive &Ar, FShaderMapEntry &Ref)
Definition ShaderCodeArchive.h:51
Definition ShaderCodeArchive.h:301
void MarkDecompressedForVisualization(int32 ShaderIndex)
Definition ShaderCodeArchive.h:368
void MarkCreatedForVisualization(int32 ShaderIndex)
Definition ShaderCodeArchive.h:369
void SaveShaderUsageBitmap(const FString &Name, EShaderPlatform ShaderPlatform)
Definition ShaderCodeArchive.h:370
void MarkPreloadedForVisualization(int32 ShaderIndex)
Definition ShaderCodeArchive.h:366
void Initialize(const int32 InNumShaders)
Definition ShaderCodeArchive.h:365
void MarkExplicitlyPreloadedForVisualization(int32 ShaderIndex)
Definition ShaderCodeArchive.h:367