UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MetalBindlessDescriptors.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2// Copyright Epic Games, Inc. All Rights Reserved.
3
4#pragma once
5
6#include "MetalRHIPrivate.h"
7
8#if PLATFORM_SUPPORTS_BINDLESS_RENDERING
9#include "MetalResources.h"
12
14class FMetalDevice;
15
17
19{
21 GPU,
22};
23
25{
26 TArray<uint32> Indices;
28
29 int32 Num() const
30 {
31 return Indices.Num();
32 }
33
35 {
36 if (ensure(InHandle.IsValid()))
37 {
38 Indices.Emplace(InHandle.GetIndex());
39 Descriptors.Emplace(InDescriptor);
40 }
41 }
42
43 void Empty()
44 {
45 Indices.Empty();
46 Descriptors.Empty();
47 }
48};
49
51{
54
55 void Init(FRHICommandListBase& RHICmdList, int32 HeapSize);
56
57 FRHIDescriptorHandle AllocateDescriptor(ERHIDescriptorType DescriptorType);
59 void FreeDescriptor(FRHIDescriptorHandle DescriptorHandle);
60
62 void BindToEncoder(FMetalCommandEncoder* Encoder, MTL::FunctionType FunctionType, uint32 BindIndex);
63
64 ERHIDescriptorTypeMask GetTypeMask() const
65 {
66 return TypeMask;
67 }
68
69 bool HandlesAllocation(ERHIDescriptorType InType) const
70 {
72 }
73
74 FMetalRHIBuffer* GetHeap() const
75 {
76 return ResourceHeap.GetReference();
77 }
78
79private:
81 {
82 checkSlow(ResourceHeap != nullptr);
83 return reinterpret_cast<IRDescriptorTableEntry*>(ResourceHeap->GetCurrentBuffer()->Contents());
84 }
85
86 FMetalDevice& Device;
87
88 FRHIHeapDescriptorAllocator* Manager = nullptr;
90
92};
93
95{
96public:
99
100 void Init();
101
102 FRHIDescriptorHandle AllocateDescriptor(ERHIDescriptorType DescriptorType);
103 FRHIDescriptorHandle AllocateDescriptor(ERHIDescriptorType DescriptorType, MTL::Texture* Texture);
104 FRHIDescriptorHandle AllocateDescriptor(ERHIDescriptorType DescriptorType, FMetalBuffer* Buffer, const uint32_t ExtraOffset = 0);
105 FRHIDescriptorHandle AllocateDescriptor(MTL::SamplerState* SamplerState);
106
107 void FreeDescriptor(FRHIDescriptorHandle DescriptorHandle);
108
109 void UpdateDescriptor(FRHICommandListBase& RHICmdList, FRHIDescriptorHandle DescriptorHandle, MTL::Texture* Texture, EMetalDescriptorUpdateType UpdateType);
111
113 void BindDescriptorHeapsToEncoder(FMetalCommandEncoder* Encoder, MTL::FunctionType FunctionType, EMetalShaderStages Frequency);
114
115 bool IsSupported() const
116 {
117 return bIsSupported;
118 }
119
120private:
121 FMetalDevice& Device;
122
125
126 bool bIsSupported = false;
127};
128
129#endif
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define ensure( InExpression)
Definition AssertionMacros.h:464
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
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
void Init()
Definition LockFreeList.h:4
EMetalShaderStages
Definition MetalRHIPrivate.h:222
@ Num
Definition MetalRHIPrivate.h:234
ERHIDescriptorTypeMask
Definition RHIDefinitions.h:1367
ERHIDescriptorType
Definition RHIDefinitions.h:1348
constexpr ERHIDescriptorTypeMask RHIDescriptorTypeMaskFromType(ERHIDescriptorType InType)
Definition RHIDefinitions.h:1391
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MetalResources.h:54
Definition MetalCommandEncoder.h:149
Definition MetalDevice.h:102
Definition MetalResources.h:365
Definition MetalRHIContext.h:48
Definition MetalResources.h:458
Definition RHICommandList.h:455
Definition RHIDescriptorAllocator.h:87
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_FORCEINLINE_HINT SizeType Emplace(ArgsType &&... Args)
Definition Array.h:2561
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition RefCounting.h:454
Definition RHIDefinitions.h:1401