UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MetalUniformBuffer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5//
6// Implements handles to linearly allocated per-frame constant buffers for shared memory systems.
7//
8
9#import "MetalThirdParty.h"
10#include "MetalBuffer.h"
11#include "RHIResources.h"
12
13#define METAL_UNIFORM_BUFFER_VALIDATION !UE_BUILD_SHIPPING
14
16class FMetalDevice;
17
19{
20 friend class FMetalStateCache;
21public:
22 // The last render thread frame this uniform buffer updated or pushed contents to the GPU backing
24
26
27 // CPU side shadow memory to hold updates for single-draw or multi-frame buffers.
28 // This allows you to upload on a frame but actually use this UB later on
29 void* Shadow;
30
31private:
32 FMetalDevice& Device;
33#if METAL_UNIFORM_BUFFER_VALIDATION
35#endif
36
37public:
38 // Creates a uniform buffer.
39 // If Usage is SingleDraw or MultiFrame we will keep a copy of the data
43
44 void Update(const void* Contents);
45
46private:
47 // Copies the RDG resources to a resource table for a deferred update on the RHI thread.
48 void CopyResourceTable(const void* Contents, TArray<TRefCountPtr<FRHIResource> >& OutResourceTable) const;
49
50 // Pushes the data in Contents to the gpu.
51 // Updates the frame counter to FrameNumber.
52 // (this is to support the case where we create buffer and reuse it many frames later).
53 // This acquires a region in the current frame's transient uniform buffer
54 // and copies Contents into that backing.
55 // The amount of data is determined by the Layout
56 void PushToGPUBacking(const void* Contents);
57};
58
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FMetalSuballocatedUniformBuffer FMetalUniformBuffer
Definition MetalUniformBuffer.h:59
EUniformBufferUsage
Definition RHIDefinitions.h:536
EUniformBufferValidation
Definition RHIDefinitions.h:546
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MetalDevice.h:102
Definition MetalStateCache.h:45
Definition MetalUniformBuffer.h:19
~FMetalSuballocatedUniformBuffer()
Definition MetalUniformBuffer.cpp:36
void * Shadow
Definition MetalUniformBuffer.h:29
FMetalBufferPtr BackingBuffer
Definition MetalUniformBuffer.h:25
uint32 LastFrameUpdated
Definition MetalUniformBuffer.h:23
Definition RHIResources.h:1232
Definition Array.h:670
Definition RefCounting.h:454
Definition RHIResources.h:1150