UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MetalShaderLibrary.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 MetalShaderLibrary.h: Metal RHI Shader Library Class.
5=============================================================================*/
6
7#pragma once
8
9#include "MetalRHIPrivate.h"
11#include "RHIShaderLibrary.h"
12#include "ShaderCodeArchive.h"
14
15class FMetalDevice;
16
18{
19public:
20
27
35
36#if !USE_MMAPPED_SHADERARCHIVE
38#else
40private:
42public:
45 FString const& Name,
46 const FString& InShaderLibraryFilename,
52 :
54 {
56 }
57#endif
58
61
64 FString const& Name,
65 const FString& InShaderLibraryFilename,
70
71 virtual ~FMetalShaderLibrary();
72
73 virtual bool IsNativeLibrary() const override final;
74
79 virtual int32 GetShaderIndex(int32 ShaderMapIndex, int32 i) const override;
80
83 virtual FSHAHash GetShaderHash(int32 ShaderMapIndex, int32 ShaderIndex) override
84 {
85 return SerializedShaders.GetShaderHashes()[GetShaderIndex(ShaderMapIndex, ShaderIndex)];
86 };
87
88 virtual FSHAHash GetShaderMapHash(int32 ShaderMapIndex) const override
89 {
90 return SerializedShaders.GetShaderMapHashes()[ShaderMapIndex];
91 };
92
93 virtual bool PreloadShader(int32 ShaderIndex, FGraphEventArray& OutCompletionEvents) override { return false; }
94 virtual bool PreloadShaderMap(int32 ShaderMapIndex, FGraphEventArray& OutCompletionEvents) override { return false; }
95
96 virtual TRefCountPtr<FRHIShader> CreateShader(int32 Index, bool bRequired = true) override;
97
98private:
99 FMetalDevice& Device;
100 FString ShaderLibraryFilename;
102 FSerializedShaderArchive SerializedShaders;
103 FShaderCodeArrayType ShaderCode;
105#if !UE_BUILD_SHIPPING
106 class FMetalShaderDebugZipFile* DebugFile;
107#endif
108};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
EShaderPlatform
Definition RHIShaderPlatform.h:11
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MetalDevice.h:102
Definition MetalShaderDebugZipFile.h:17
Definition MetalShaderLibrary.h:18
virtual FSHAHash GetShaderMapHash(int32 ShaderMapIndex) const override
Definition MetalShaderLibrary.h:88
virtual ~FMetalShaderLibrary()
Definition MetalShaderLibrary.cpp:95
virtual int32 GetNumShaderMaps() const override
Definition MetalShaderLibrary.cpp:111
virtual uint32 GetSizeBytes() const override
Definition MetalShaderLibrary.cpp:116
static FCriticalSection LoadedShaderLibraryMutex
Definition MetalShaderLibrary.h:59
TArray< uint8 > FShaderCodeArrayType
Definition MetalShaderLibrary.h:37
virtual int32 GetNumShaders() const override
Definition MetalShaderLibrary.cpp:106
virtual bool PreloadShaderMap(int32 ShaderMapIndex, FGraphEventArray &OutCompletionEvents) override
Definition MetalShaderLibrary.h:94
virtual int32 GetShaderIndex(int32 ShaderMapIndex, int32 i) const override
Definition MetalShaderLibrary.cpp:130
virtual TRefCountPtr< FRHIShader > CreateShader(int32 Index, bool bRequired=true) override
Definition MetalShaderLibrary.cpp:146
virtual FSHAHash GetShaderHash(int32 ShaderMapIndex, int32 ShaderIndex) override
Definition MetalShaderLibrary.h:83
virtual bool PreloadShader(int32 ShaderIndex, FGraphEventArray &OutCompletionEvents) override
Definition MetalShaderLibrary.h:93
static TMap< FString, FRHIShaderLibrary * > LoadedShaderLibraryMap
Definition MetalShaderLibrary.h:60
virtual int32 FindShaderMapIndex(const FSHAHash &Hash) override
Definition MetalShaderLibrary.cpp:136
virtual int32 FindShaderIndex(const FSHAHash &Hash) override
Definition MetalShaderLibrary.cpp:141
virtual int32 GetNumShadersForShaderMap(int32 ShaderMapIndex) const override
Definition MetalShaderLibrary.cpp:125
virtual bool IsNativeLibrary() const override final
Definition MetalShaderLibrary.cpp:101
Definition RHIShaderLibrary.h:13
EShaderPlatform Platform
Definition RHIShaderLibrary.h:49
Definition SecureHash.h:226
Definition ShaderCodeArchive.h:89
const TArrayView< const FSHAHash > GetShaderMapHashes() const
Definition ShaderCodeArchive.h:125
const TArrayView< const FSHAHash > GetShaderHashes() const
Definition ShaderCodeArchive.h:124
Definition ArrayView.h:139
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition RefCounting.h:454
Definition UniquePtr.h:107
Definition Mutex.h:18
U16 Index
Definition radfft.cpp:71
Definition MetalShaderResources.h:273
Definition MetalShaderLibrary.h:29
UE::FMutex LibraryLock
Definition MetalShaderLibrary.h:33
TUniquePtr< FShaderLibDataOwner > Data
Definition MetalShaderLibrary.h:32
FString MetalLibraryFilePath
Definition MetalShaderLibrary.h:31
MTLLibraryPtr Library
Definition MetalShaderLibrary.h:30
Definition MetalShaderLibrary.h:22
TUniquePtr< IMappedFileRegion > MappedRegion
Definition MetalShaderLibrary.h:25
TUniquePtr< IMappedFileHandle > MappedCacheFile
Definition MetalShaderLibrary.h:24
TArray< uint8 > Mem
Definition MetalShaderLibrary.h:23