UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BoundShaderStateHistory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "RHIGlobals.h"
6#include "RenderResource.h"
7
12template<uint32 Size, bool TThreadSafe = true>
14{
15public:
17
19 inline void Add(FRHIBoundShaderState* BoundShaderState)
20 {
22 {
23 BoundShaderStateHistoryLock.Lock();
24 }
25 BoundShaderStates[NextBoundShaderStateIndex] = BoundShaderState;
26 NextBoundShaderStateIndex = (NextBoundShaderStateIndex + 1) % Size;
28 {
29 BoundShaderStateHistoryLock.Unlock();
30 }
31 }
32
34 {
36 // % doesn't work as we want on negative numbers, so handle the wraparound manually
37 uint32 LastIndex = NextBoundShaderStateIndex == 0 ? Size - 1 : NextBoundShaderStateIndex - 1;
38 return BoundShaderStates[LastIndex];
39 }
40
41 // FRenderResource interface.
42 virtual void ReleaseRHI()
43 {
45 {
46 BoundShaderStateHistoryLock.Lock();
47 }
48 for (uint32 Index = 0; Index < Size; Index++)
49 {
50 BoundShaderStates[Index].SafeRelease();
51 }
53 {
54 BoundShaderStateHistoryLock.Unlock();
55 }
56 }
57
58private:
59 FBoundShaderStateRHIRef BoundShaderStates[Size];
60 uint32 NextBoundShaderStateIndex = 0;
61 FCriticalSection BoundShaderStateHistoryLock;
62};
63
64#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
65#include "RHI.h"
66#endif
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define GRHISupportsParallelRHIExecute
Definition RHIGlobals.h:872
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition RHIResources.h:733
Definition RenderResource.h:37
Definition BoundShaderStateHistory.h:14
FRHIBoundShaderState * GetLast()
Definition BoundShaderStateHistory.h:33
TBoundShaderStateHistory()=default
virtual void ReleaseRHI()
Definition BoundShaderStateHistory.h:42
void Add(FRHIBoundShaderState *BoundShaderState)
Definition BoundShaderStateHistory.h:19
UE_FORCEINLINE_HINT void SafeRelease()
Definition RefCounting.h:599
U16 Index
Definition radfft.cpp:71