UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
D3D12StateCachePrivate.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Implementation of Device Context State Caching to improve draw
4// thread performance by removing redundant device context calls.
5
6#pragma once
7
11// TODO reorder includes so we just include D3D12PipelineState.h here
12#include COMPILED_PLATFORM_HEADER(D3D12PipelineState.h)
13#include "D3D12Resources.h"
14
15#include "Math/IntVector.h"
16
18
20
24struct FD3D12ShaderData;
25
26//-----------------------------------------------------------------------------
27// Configuration
28//-----------------------------------------------------------------------------
29
30// If set, includes a runtime toggle console command for debugging D3D12 state caching.
31// ("TOGGLESTATECACHE")
32#define D3D12_STATE_CACHE_RUNTIME_TOGGLE 0
33
34// Uncomment only for debugging of the descriptor heap management; this is very noisy
35//#define VERBOSE_DESCRIPTOR_HEAP_DEBUG 1
36
37// The number of view descriptors available per (online) descriptor heap, depending on hardware tier
38#define NUM_SAMPLER_DESCRIPTORS D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE
39
40// Keep set state functions inline to reduce call overhead
41#define D3D12_STATE_CACHE_INLINE FORCEINLINE_DEBUGGABLE
42
43#if D3D12_STATE_CACHE_RUNTIME_TOGGLE
44extern bool GD3D12SkipStateCaching;
45#else
46static const bool GD3D12SkipStateCaching = false;
47#endif
48
51
57
59{
61 Compute,
63};
64
66{
67 constexpr int32 PerPrimitive = 0;
69 constexpr int32 Num = ScreenSpace + 1;
70};
71
72#define MAX_VBS D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
73
75static_assert((8 * sizeof(VBSlotMask)) >= MAX_VBS, "VBSlotMask isn't large enough to cover all VBs. Please increase the size.");
76
99
114
115template<typename ResourceSlotMask>
117{
118 static inline void CleanSlot(ResourceSlotMask& SlotMask, uint32 SlotIndex)
119 {
120 SlotMask &= ~((ResourceSlotMask)1 << SlotIndex);
121 }
122
123 static inline void CleanSlots(ResourceSlotMask& SlotMask, uint32 NumSlots)
124 {
125 SlotMask &= (NumSlots >= std::numeric_limits<ResourceSlotMask>::digits) ? 0 : ~(((ResourceSlotMask)1 << NumSlots) - 1);
126 }
127
128 static inline void DirtySlot(ResourceSlotMask& SlotMask, uint32 SlotIndex)
129 {
130 SlotMask |= ((ResourceSlotMask)1 << SlotIndex);
131 }
132
133 static inline bool IsSlotDirty(const ResourceSlotMask& SlotMask, uint32 SlotIndex)
134 {
135 return (SlotMask & ((ResourceSlotMask)1 << SlotIndex)) != 0;
136 }
137
138 // Mark a specific shader stage as dirty.
139 inline void Dirty(EShaderFrequency ShaderFrequency, const ResourceSlotMask& SlotMask = -1)
140 {
141 checkSlow(ShaderFrequency < UE_ARRAY_COUNT(DirtySlotMask));
142 DirtySlotMask[ShaderFrequency] |= SlotMask;
143 }
144
145 // Mark specified bind slots, on all graphics stages, as dirty.
154
155 // Mark specified bind slots on compute as dirty.
156 inline void DirtyCompute(const ResourceSlotMask& SlotMask = -1)
157 {
159 }
160
161 // Mark specified bind slots on graphics and compute as dirty.
162 inline void DirtyAll(const ResourceSlotMask& SlotMask = -1)
163 {
166 }
167
169};
170
172{
174 {
175 Clear();
176 }
177
178 inline void Clear()
179 {
180 DirtyAll();
181
184#if D3D12RHI_USE_CONSTANT_BUFFER_VIEWS
186#endif
187 }
188
189#if D3D12RHI_USE_CONSTANT_BUFFER_VIEWS
190 D3D12_CPU_DESCRIPTOR_HANDLE CBHandles[SF_NumStandardFrequencies][MAX_CBS];
191#endif
194};
195
230
255
256struct FD3D12SamplerStateCache : public FD3D12ResourceCache<SamplerSlotMask>
257{
259 {
260 Clear();
261 }
262
263 inline void Clear()
264 {
265 DirtyAll();
266
268 }
269
271};
272
273
274static inline D3D_PRIMITIVE_TOPOLOGY GetD3D12PrimitiveType(uint32 PrimitiveType)
275{
276 static const uint8 D3D12PrimitiveType[] =
277 {
278 D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, // PT_TriangleList
279 D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, // PT_TriangleStrip
280 D3D_PRIMITIVE_TOPOLOGY_LINELIST, // PT_LineList
281 0, // PT_QuadList
282 D3D_PRIMITIVE_TOPOLOGY_POINTLIST, // PT_PointList
283#if defined(D3D12RHI_PRIMITIVE_TOPOLOGY_RECTLIST) // PT_RectList
285#else
286 0,
287#endif
288 };
289 static_assert(UE_ARRAY_COUNT(D3D12PrimitiveType) == PT_Num, "Primitive lookup table is wrong size");
290
292 checkf(D3DType, TEXT("Unknown primitive type: %u"), PrimitiveType);
293 return D3DType;
294}
295
296//-----------------------------------------------------------------------------
297// FD3D12StateCache Class Definition
298//-----------------------------------------------------------------------------
300{
301 friend class FD3D12DynamicRHI;
302
303protected:
305
306 bool bNeedSetVB = true;
307 bool bNeedSetRTs = true;
308 bool bNeedSetViewports = true;
316
317 bool bSRVSCleared = true;
318
320
321 struct
322 {
323 struct FGraphicsState
324 {
325 // Cache
326 TRefCountPtr<FD3D12GraphicsPipelineState> CurrentPipelineStateObject = nullptr;
327
328 // Note: Current root signature is part of the bound shader state, which is part of the PSO
330
331 // Depth Stencil State Cache
332 uint32 CurrentReferenceStencil = D3D12_DEFAULT_STENCIL_REFERENCE;
333
334 // Blend State Cache
342
343 // Viewport
344 uint32 CurrentNumberOfViewports = 0;
346
347 // Vertex Buffer State
349
350 // Index Buffer State
352
353 // Primitive Topology State
354 EPrimitiveType CurrentPrimitiveType = PT_Num;
358
359 // Input Layout State
361 uint32 CurrentNumberOfScissorRects = 0;
362
364
366 uint32 CurrentNumberOfRenderTargets = 0;
367
368 FD3D12DepthStencilView* CurrentDepthStencilTarget = nullptr;
369
370 float MinDepth = 0.0f;
371 float MaxDepth = 1.0f;
372
374
376
377 FD3D12Resource* ShadingRateImage = nullptr;
378
379 FGraphicsState()
380 {
381 for (auto& Combiner : Combiners)
382 {
384 }
385 }
386 } Graphics = {};
387
388 struct
389 {
390 // Cache
392
393 // Note: Current root signature is part of the bound compute shader, which is part of the PSO
395
396 // Need to cache compute budget, as we need to reset if after PSO changes
398 } Compute = {};
399
400 struct
401 {
406
407 // PSO
410
411 // Root Constants
414
419
420#if PLATFORM_SUPPORTS_BINDLESS_RENDERING
423#endif
424 } Common = {};
426
428
431
432 bool InternalSetDescriptorHeaps(bool bBindless);
435
436private:
437
438 // SetDirtyUniformBuffers and SetPipelineState helper functions are required
439 // to allow using FD3D12CommandContext type which is not defined at this point.
440 // Making ContextType a template parameter delays instantiation of these functions.
441
442 template <typename ContextType>
443 static void SetDirtyUniformBuffers(ContextType& Context, EShaderFrequency Frequency)
444 {
445 Context.DirtyUniformBuffers[Frequency] = 0xffff;
446 }
447
448public:
449
454
456 {
457 return PipelineState.Graphics.CurrentPipelineStateObject;
458 }
459
461 {
462 return PipelineState.Compute.CurrentPipelineStateObject;
463 }
464
466 {
467 return PipelineState.Graphics.CurrentPrimitiveType;
468 }
469
471 {
472 return PipelineState.Graphics.PrimitiveTypeFactor * NumPrimitives + PipelineState.Graphics.PrimitiveTypeOffset;
473 }
474
475 void ClearSRVs();
476
478
479 void SetShaderResourceView(EShaderFrequency ShaderFrequency, FD3D12ShaderResourceView* SRV, uint32 ResourceIndex);
480
482 void SetScissorRect(const D3D12_RECT& ScissorRect);
483
485 {
486 return PipelineState.Graphics.CurrentScissorRects[Index];
487 }
488
489 void SetViewport(const D3D12_VIEWPORT& Viewport);
490 void SetViewports(uint32 Count, const D3D12_VIEWPORT* const Viewports);
491
493 {
494 return PipelineState.Graphics.CurrentNumberOfViewports;
495 }
496
498 {
499 return PipelineState.Graphics.CurrentViewport[Index];
500 }
501
503 {
504 check(*Count);
505 if (Viewports) //NULL is legal if you just want count
506 {
507 //as per d3d spec
508 const int32 StorageSizeCount = (int32)(*Count);
509 const int32 CopyCount = FMath::Min(FMath::Min(StorageSizeCount, (int32)PipelineState.Graphics.CurrentNumberOfViewports), D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE);
510 if (CopyCount > 0)
511 {
512 FMemory::Memcpy(Viewports, &PipelineState.Graphics.CurrentViewport[0], sizeof(D3D12_VIEWPORT) * CopyCount);
513 }
514 //remaining viewports in supplied array must be set to zero
516 {
518 }
519 }
520 *Count = PipelineState.Graphics.CurrentNumberOfViewports;
521 }
522
524 {
526 auto& Samplers = PipelineState.Common.SamplerCache.States[ShaderFrequency];
527 if ((Samplers[SamplerIndex] != SamplerState) || GD3D12SkipStateCaching)
528 {
529 Samplers[SamplerIndex] = SamplerState;
530 FD3D12SamplerStateCache::DirtySlot(PipelineState.Common.SamplerCache.DirtySlotMask[ShaderFrequency], SamplerIndex);
531 }
532 }
533
535 {
536 check(SlotIndex < MAX_CBS);
538 D3D12_GPU_VIRTUAL_ADDRESS& CurrentGPUVirtualAddress = CBVCache.CurrentGPUVirtualAddress[ShaderFrequency][SlotIndex];
539
540 if (UniformBuffer && UniformBuffer->ResourceLocation.GetGPUVirtualAddress())
541 {
542 const FD3D12ResourceLocation& ResourceLocation = UniformBuffer->ResourceLocation;
543 // Only update the constant buffer if it has changed.
544 if (ResourceLocation.GetGPUVirtualAddress() != CurrentGPUVirtualAddress)
545 {
546 CurrentGPUVirtualAddress = ResourceLocation.GetGPUVirtualAddress();
547 CBVCache.Resources[ShaderFrequency][SlotIndex] = ResourceLocation.GetResource();
549 }
550
551#if D3D12RHI_USE_CONSTANT_BUFFER_VIEWS
552 CBVCache.CBHandles[ShaderFrequency][SlotIndex] = UniformBuffer->View->GetOfflineCpuHandle();
553#endif
554 }
555 else if (CurrentGPUVirtualAddress != 0)
556 {
557 CurrentGPUVirtualAddress = 0;
558 CBVCache.Resources[ShaderFrequency][SlotIndex] = {};
560#if D3D12RHI_USE_CONSTANT_BUFFER_VIEWS
561 CBVCache.CBHandles[ShaderFrequency][SlotIndex].ptr = 0;
562#endif
563 }
564 else
565 {
566#if D3D12RHI_USE_CONSTANT_BUFFER_VIEWS
567 CBVCache.CBHandles[ShaderFrequency][SlotIndex].ptr = 0;
568#endif
569 }
570 }
571
572 D3D12_STATE_CACHE_INLINE void SetConstantBuffer(EShaderFrequency ShaderFrequency, FD3D12ConstantBuffer& Buffer, bool bDiscardSharedConstants)
573 {
575
576 if (Buffer.Version(Location, bDiscardSharedConstants))
577 {
578 // Note: Code assumes the slot index is always 0.
579 const uint32 SlotIndex = 0;
580
582 D3D12_GPU_VIRTUAL_ADDRESS& CurrentGPUVirtualAddress = CBVCache.CurrentGPUVirtualAddress[ShaderFrequency][SlotIndex];
583 check(Location.GetGPUVirtualAddress() != CurrentGPUVirtualAddress);
584 CurrentGPUVirtualAddress = Location.GetGPUVirtualAddress();
585 CBVCache.Resources[ShaderFrequency][SlotIndex] = Location.GetResource();
587
588#if D3D12RHI_USE_CONSTANT_BUFFER_VIEWS
589 CBVCache.CBHandles[ShaderFrequency][SlotIndex] = Buffer.GetOfflineCpuHandle();
590#endif
591 }
592 }
593
594 void SetBlendFactor(const float BlendFactor[4]);
596
610
613 void SetComputePipelineState(FD3D12ComputePipelineState* ComputePipelineState);
614
616 {
617 ensure(Stride == PipelineState.Graphics.StreamStrides[StreamIndex]);
619 }
620
625
627 {
628 for (int32 index = 0; index <= PipelineState.Graphics.VBCache.MaxBoundVertexBufferIndex; ++index)
629 {
630 if (PipelineState.Graphics.VBCache.CurrentVertexBufferResources[index] == VertexBufferLocation)
631 {
632 PipelineState.Graphics.VBCache.CurrentVertexBufferResources[index] = nullptr;
633 }
634 }
635 }
636
637public:
638
640 {
642 UINT SizeInBytes = IndexBufferLocation.GetSize() - Offset;
643
644 D3D12_INDEX_BUFFER_VIEW& CurrentView = PipelineState.Graphics.IBCache.CurrentIndexBufferView;
645
646 if (BufferLocation != CurrentView.BufferLocation ||
647 SizeInBytes != CurrentView.SizeInBytes ||
648 Format != CurrentView.Format ||
649 GD3D12SkipStateCaching)
650 {
651 CurrentView.BufferLocation = BufferLocation;
652 CurrentView.SizeInBytes = SizeInBytes;
653 CurrentView.Format = Format;
654
656 }
657 }
658
660 ~FD3D12StateCache() = default;
661
662#if D3D12_RHI_RAYTRACING
663 // When transitioning between RayGen and Compute, it is necessary to clear the state cache
665 {
666 if (LastComputePipelineType != PipelineType)
667 {
668 PipelineState.Common.bNeedSetPSO = true;
669 PipelineState.Common.bNeedSetRootConstants = true;
670 PipelineState.Compute.bNeedSetRootSignature = true;
671
672 LastComputePipelineType = PipelineType;
673 }
674 }
675
677#endif // D3D12_RHI_RAYTRACING
678
685 void DirtyState();
689
692 {
693 if (RTArray) //NULL is legal
694 {
697 *NumSimultaneousRTs = PipelineState.Graphics.CurrentNumberOfRenderTargets;
698 }
699
700 if (DepthStencilTarget)
701 {
702 *DepthStencilTarget = PipelineState.Graphics.CurrentDepthStencilTarget;
703 }
704 }
705
706 void SetRootConstants(const FUint32Vector4& Constants);
707
709
711
713 {
714 if (PipelineState.Graphics.MinDepth != MinDepth || PipelineState.Graphics.MaxDepth != MaxDepth)
715 {
716 PipelineState.Graphics.MinDepth = MinDepth;
717 PipelineState.Graphics.MaxDepth = MaxDepth;
718
720 }
721 }
722
735
737 {
738 if (PipelineState.Graphics.ShadingRateImage != ShadingRateImage)
739 {
740 PipelineState.Graphics.ShadingRateImage = ShadingRateImage;
742 }
743 }
744
746 {
747 PipelineState.Compute.ComputeBudget = ComputeBudget;
748 }
749
750 void FlushComputeShaderCache(bool bForce = false);
751
757 void ClearState();
758
759 void ForceSetComputeRootSignature() { PipelineState.Compute.bNeedSetRootSignature = true; }
760 void ForceSetGraphicsRootSignature() { PipelineState.Graphics.bNeedSetRootSignature = true; }
761
762#if PLATFORM_SUPPORTS_BINDLESS_RENDERING
765
767 {
768 // If we just switched to a new bindless heap, we have to make sure to set the RootSignatures again.
769 PipelineState.Compute.bNeedSetRootSignature = true;
770 PipelineState.Graphics.bNeedSetRootSignature = true;
771 }
772
774 {
775 PipelineState.Common.QueuedBindlessSRVs[ShaderFrequency].Emplace(SRV);
776 }
778 {
779 PipelineState.Common.QueuedBindlessSRVs[ShaderFrequency].Append(SRVs);
780 }
782 {
783 PipelineState.Common.QueuedBindlessUAVs[ShaderFrequency].Emplace(UAV);
784 }
786 {
787 PipelineState.Common.QueuedBindlessUAVs[ShaderFrequency].Append(UAVs);
788 }
789#endif
790};
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define TEXT(x)
Definition Platform.h:1272
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
uint32 SRVSlotMask
Definition D3D12RHICommon.h:40
#define MAX_UAVS
Definition D3D12RHI.h:19
#define MAX_SAMPLERS
Definition D3D12RHI.h:18
#define MAX_CBS
Definition D3D12RHI.h:20
#define MAX_SRVS
Definition D3D12RHI.h:17
int32 GOnlineDescriptorHeapBlockSize
Definition D3D12StateCache.cpp:56
int32 GBindlessOnlineDescriptorHeapSize
Definition D3D12StateCache.cpp:64
ED3D12PipelineType
Definition D3D12StateCachePrivate.h:59
#define D3D12_STATE_CACHE_INLINE
Definition D3D12StateCachePrivate.h:41
int32 GBindlessOnlineDescriptorHeapBlockSize
Definition D3D12StateCache.cpp:72
#define MAX_VBS
Definition D3D12StateCachePrivate.h:72
int32 GGlobalResourceDescriptorHeapSize
Definition D3D12StateCache.cpp:11
int32 GGlobalSamplerHeapSize
Definition D3D12StateCache.cpp:37
int32 GOnlineDescriptorHeapSize
Definition D3D12StateCache.cpp:48
uint32 VBSlotMask
Definition D3D12StateCachePrivate.h:74
int32 GGlobalSamplerDescriptorHeapSize
Definition D3D12StateCache.cpp:19
UE::Math::TIntVector4< uint32 > FUint32Vector4
Definition MathFwd.h:108
EShaderFrequency
Definition RHIDefinitions.h:202
@ SF_Compute
Definition RHIDefinitions.h:208
@ SF_Amplification
Definition RHIDefinitions.h:205
@ SF_Vertex
Definition RHIDefinitions.h:203
@ SF_Mesh
Definition RHIDefinitions.h:204
@ SF_Geometry
Definition RHIDefinitions.h:207
@ SF_Pixel
Definition RHIDefinitions.h:206
@ SF_NumStandardFrequencies
Definition RHIDefinitions.h:222
EVRSRateCombiner
Definition RHIDefinitions.h:873
@ VRSRB_Passthrough
Definition RHIDefinitions.h:874
EAsyncComputeBudget
Definition RHIDefinitions.h:1317
EPrimitiveType
Definition RHIDefinitions.h:822
@ PT_Num
Definition RHIDefinitions.h:846
EVRSShadingRate
Definition RHIDefinitions.h:860
@ VRSSR_1x1
Definition RHIDefinitions.h:861
#define GSupportsDepthBoundsTest
Definition RHIGlobals.h:807
#define GRHISupportsAttachmentVariableRateShading
Definition RHIGlobals.h:884
#define GRHISupportsPipelineVariableRateShading
Definition RHIGlobals.h:882
ERHIPipeline
Definition RHIPipeline.h:13
EShaderParameterTypeMask
Definition ShaderCore.h:263
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
uint32 Offset
Definition VulkanMemory.cpp:4033
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition D3D12CommandContext.h:513
Definition D3D12ConstantBuffer.h:20
Definition D3D12View.h:435
Definition D3D12DescriptorCache.h:312
Definition D3D12RHICommon.h:78
FORCEINLINE FD3D12Device * GetParentDevice() const
Definition D3D12RHICommon.h:85
Definition D3D12RHIPrivate.h:160
Definition D3D12View.h:423
Definition D3D12Resources.h:641
FD3D12Resource * GetResource() const
Definition D3D12Resources.h:700
D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const
Definition D3D12Resources.h:702
Definition D3D12Resources.h:181
Definition D3D12RootSignature.h:73
Definition D3D12State.h:13
Definition D3D12View.h:351
Definition D3D12RHICommon.h:128
Definition D3D12StateCachePrivate.h:300
bool bSRVSCleared
Definition D3D12StateCachePrivate.h:317
FD3D12ShaderResourceViewCache SRVCache
Definition D3D12StateCachePrivate.h:402
void InternalSetPipelineState(FD3D12PipelineState *InPipelineState)
Definition D3D12StateCache.cpp:413
void SetRootConstants(const FUint32Vector4 &Constants)
Definition D3D12StateCache.cpp:1297
void SetRenderTargets(uint32 NumSimultaneousRenderTargets, FD3D12RenderTargetView **RTArray, FD3D12DepthStencilView *DSTarget)
Definition D3D12StateCache.cpp:1603
uint32 PrimitiveTypeFactor
Definition D3D12StateCachePrivate.h:356
uint32 CurrentShaderUAVCounts[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:418
bool bNeedSetRootConstants
Definition D3D12StateCachePrivate.h:412
bool bNeedSetRTs
Definition D3D12StateCachePrivate.h:307
struct FD3D12StateCache::@931 PipelineState
bool bNeedSetStencilRef
Definition D3D12StateCachePrivate.h:312
FD3D12UnorderedAccessViewCache UAVCache
Definition D3D12StateCachePrivate.h:404
TStaticArray< EVRSRateCombiner, ED3D12VRSCombinerStages::Num > Combiners
Definition D3D12StateCachePrivate.h:375
void SetComputePipelineState(FD3D12ComputePipelineState *ComputePipelineState)
Definition D3D12StateCache.cpp:1411
D3D12_STATE_CACHE_INLINE void SetIndexBuffer(const FD3D12ResourceLocation &IndexBufferLocation, DXGI_FORMAT Format, uint32 Offset)
Definition D3D12StateCachePrivate.h:639
void InternalSetIndexBuffer(FD3D12Resource *Resource)
Definition D3D12StateCache.cpp:1506
D3D12_STATE_CACHE_INLINE void SetConstantsFromUniformBuffer(EShaderFrequency ShaderFrequency, uint32 SlotIndex, FD3D12UniformBuffer *UniformBuffer)
Definition D3D12StateCachePrivate.h:534
bool bNeedSetPrimitiveTopology
Definition D3D12StateCachePrivate.h:310
void ApplySamplerTables(const FD3D12RootSignature *pRootSignature, uint32 StartStage, uint32 EndStage)
Definition D3D12StateCache.cpp:934
FUint32Vector4 ShaderRootConstants
Definition D3D12StateCachePrivate.h:413
bool bNeedSetVB
Definition D3D12StateCachePrivate.h:306
void ClearSRVs()
Definition D3D12StateCache.cpp:142
bool bNeedSetRootSignature
Definition D3D12StateCachePrivate.h:329
void ApplyResourceTables(const FD3D12RootSignature *pRootSignature, uint32 StartStage, uint32 EndStage)
Definition D3D12StateCache.cpp:654
bool AssertResourceStates(ED3D12PipelineType PipelineType)
void SetDepthBounds(float MinDepth, float MaxDepth)
Definition D3D12StateCachePrivate.h:712
bool bNeedSetBlendFactor
Definition D3D12StateCachePrivate.h:311
bool InternalSetRootSignature(ED3D12PipelineType InPipelineType, const FD3D12RootSignature *InRootSignature, bool bForce)
Definition D3D12StateCache.cpp:370
uint32 CurrentShaderCBCounts[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:417
void SetScissorRect(const D3D12_RECT &ScissorRect)
Definition D3D12StateCache.cpp:325
TStaticArray< uint16, MaxVertexElementCount > StreamStrides
Definition D3D12StateCachePrivate.h:363
void SetShadingRateImage(FD3D12Resource *ShadingRateImage)
Definition D3D12StateCachePrivate.h:736
void FlushComputeShaderCache(bool bForce=false)
Definition D3D12StateCache.cpp:187
bool bNeedSetPSO
Definition D3D12StateCachePrivate.h:409
bool bNeedSetScissorRects
Definition D3D12StateCachePrivate.h:309
void ApplyState(ERHIPipeline HardwarePipe, ED3D12PipelineType PipelineType)
Definition D3D12StateCache.cpp:432
void SetShadingRate(EVRSShadingRate ShadingRate, EVRSRateCombiner PerPrimitiveCombiner, EVRSRateCombiner ScreenSpaceCombiner)
Definition D3D12StateCachePrivate.h:723
void SetUAV(EShaderFrequency ShaderStage, uint32 SlotIndex, FD3D12UnorderedAccessView *UAV, uint32 InitialCount=-1)
Definition D3D12StateCache.cpp:1321
void DirtyStateForNewCommandList()
Definition D3D12StateCache.cpp:196
FD3D12ComputePipelineState * GetComputePipelineState() const
Definition D3D12StateCachePrivate.h:460
void ForceSetGraphicsRootSignature()
Definition D3D12StateCachePrivate.h:760
float MaxDepth
Definition D3D12StateCachePrivate.h:371
D3D12_STATE_CACHE_INLINE const D3D12_RECT & GetScissorRect(int32 Index=0) const
Definition D3D12StateCachePrivate.h:484
float MinDepth
Definition D3D12StateCachePrivate.h:370
uint32 CurrentShaderSRVCounts[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:416
void SetBlendFactor(const float BlendFactor[4])
Definition D3D12StateCache.cpp:1382
void SetStencilRef(uint32 StencilRef)
Definition D3D12StateCache.cpp:1391
D3D12_STATE_CACHE_INLINE void SetSamplerState(EShaderFrequency ShaderFrequency, FD3D12SamplerState *SamplerState, uint32 SamplerIndex)
Definition D3D12StateCachePrivate.h:523
void SetShaderResourceView(EShaderFrequency ShaderFrequency, FD3D12ShaderResourceView *SRV, uint32 ResourceIndex)
Definition D3D12StateCache.cpp:1565
D3D12_RESOURCE_BINDING_TIER ResourceBindingTier
Definition D3D12StateCachePrivate.h:319
void SetViewports(uint32 Count, const D3D12_VIEWPORT *const Viewports)
Definition D3D12StateCache.cpp:293
D3D12_STATE_CACHE_INLINE void SetStreamSource(FD3D12ResourceLocation *VertexBufferLocation, uint32 StreamIndex, uint32 Stride, uint32 Offset)
Definition D3D12StateCachePrivate.h:615
FD3D12GraphicsPipelineState * GetGraphicsPipelineState() const
Definition D3D12StateCachePrivate.h:455
void InternalSetStreamSource(FD3D12ResourceLocation *VertexBufferLocation, uint32 StreamIndex, uint32 Stride, uint32 Offset)
Definition D3D12StateCache.cpp:1517
FD3D12CommandContext & CmdContext
Definition D3D12StateCachePrivate.h:304
EAsyncComputeBudget ComputeBudget
Definition D3D12StateCachePrivate.h:397
void DirtyState()
Definition D3D12StateCache.cpp:242
D3D12_STATE_CACHE_INLINE void GetRenderTargets(FD3D12RenderTargetView **RTArray, uint32 *NumSimultaneousRTs, FD3D12DepthStencilView **DepthStencilTarget)
Definition D3D12StateCachePrivate.h:691
FD3D12DescriptorCache * GetDescriptorCache()
Definition D3D12StateCachePrivate.h:450
TRefCountPtr< FD3D12GraphicsPipelineState > CurrentPipelineStateObject
Definition D3D12StateCachePrivate.h:326
void DirtySamplerDescriptorTables()
Definition D3D12StateCache.cpp:275
void ForceSetComputeRootSignature()
Definition D3D12StateCachePrivate.h:759
void SetNewShaderData(EShaderFrequency InFrequency, const FD3D12ShaderData *InShaderData)
Definition D3D12StateCache.cpp:1400
FD3D12DescriptorCache DescriptorCache
Definition D3D12StateCachePrivate.h:427
uint32 GetVertexCount(uint32 NumPrimitives)
Definition D3D12StateCachePrivate.h:470
void SetViewport(const D3D12_VIEWPORT &Viewport)
Definition D3D12StateCache.cpp:283
void SetComputeBudget(EAsyncComputeBudget ComputeBudget)
Definition D3D12StateCachePrivate.h:745
void ApplyBindlessResources(const FD3D12RootSignature *pRootSignature, uint32 StartStage, uint32 EndStage)
Definition D3D12StateCache.cpp:824
D3D12_STATE_CACHE_INLINE uint32 GetNumViewports() const
Definition D3D12StateCachePrivate.h:492
FD3D12ConstantBufferCache CBVCache
Definition D3D12StateCachePrivate.h:403
bool bNeedSetDepthBounds
Definition D3D12StateCachePrivate.h:313
uint32 PrimitiveTypeOffset
Definition D3D12StateCachePrivate.h:357
~FD3D12StateCache()=default
void SetGraphicsPipelineState(FD3D12GraphicsPipelineState *GraphicsPipelineState)
Definition D3D12StateCache.cpp:1439
D3D12_STATE_CACHE_INLINE void SetStreamSource(FD3D12ResourceLocation *VertexBufferLocation, uint32 StreamIndex, uint32 Offset)
Definition D3D12StateCachePrivate.h:621
void ClearResourceViewCaches(EShaderFrequency ShaderFrequency, FD3D12ResourceLocation *&ResourceLocation, EShaderParameterTypeMask ShaderParameterTypeMask)
Definition D3D12StateCache.cpp:154
bool bNeedSetShadingRateImage
Definition D3D12StateCachePrivate.h:315
void SetScissorRects(uint32 Count, const D3D12_RECT *const ScissorRects)
Definition D3D12StateCache.cpp:337
void ApplyConstants(const FD3D12RootSignature *pRootSignature, uint32 StartStage, uint32 EndStage)
Definition D3D12StateCache.cpp:898
void ClearUAVs(EShaderFrequency ShaderStage)
Definition D3D12StateCache.cpp:1306
D3D12_STATE_CACHE_INLINE const D3D12_VIEWPORT & GetViewport(int32 Index=0) const
Definition D3D12StateCachePrivate.h:497
D3D12_STATE_CACHE_INLINE void GetViewports(uint32 *Count, D3D12_VIEWPORT *Viewports) const
Definition D3D12StateCachePrivate.h:502
FRHIShader * GetShader(EShaderFrequency InFrequency)
Definition D3D12StateCachePrivate.h:597
void ClearState()
Definition D3D12StateCache.cpp:136
D3D12_STATE_CACHE_INLINE void ClearVertexBuffer(const FD3D12ResourceLocation *VertexBufferLocation)
Definition D3D12StateCachePrivate.h:626
bool InternalSetDescriptorHeaps(bool bBindless)
Definition D3D12StateCache.cpp:354
struct FD3D12StateCache::@931::FGraphicsState Graphics
EPrimitiveType GetGraphicsPipelinePrimitiveType() const
Definition D3D12StateCachePrivate.h:465
bool bNeedSetShadingRate
Definition D3D12StateCachePrivate.h:314
FD3D12SamplerStateCache SamplerCache
Definition D3D12StateCachePrivate.h:405
struct FD3D12StateCache::@931::@933 Common
bool bNeedSetViewports
Definition D3D12StateCachePrivate.h:308
FD3D12Resource * ShadingRateImage
Definition D3D12StateCachePrivate.h:377
struct FD3D12StateCache::@931::@932 Compute
void DirtyViewDescriptorTables()
Definition D3D12StateCache.cpp:265
D3D12_STATE_CACHE_INLINE void SetConstantBuffer(EShaderFrequency ShaderFrequency, FD3D12ConstantBuffer &Buffer, bool bDiscardSharedConstants)
Definition D3D12StateCachePrivate.h:572
uint32 CurrentShaderSamplerCounts[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:415
Definition D3D12Resources.h:956
Definition D3D12View.h:388
FRHIComputeShader * GetComputeShader() const
Definition RHIResources.h:1092
Definition RHIResources.h:854
Definition Array.h:670
Definition RefCounting.h:454
Definition StaticArray.h:26
Definition D3D12StateCachePrivate.h:66
constexpr int32 Num
Definition D3D12StateCachePrivate.h:69
constexpr int32 PerPrimitive
Definition D3D12StateCachePrivate.h:67
constexpr int32 ScreenSpace
Definition D3D12StateCachePrivate.h:68
Definition VulkanCommon.h:29
U16 Index
Definition radfft.cpp:71
Definition D3D12PipelineState.h:424
Definition D3D12StateCachePrivate.h:172
FD3D12Resource * Resources[SF_NumStandardFrequencies][MAX_CBS]
Definition D3D12StateCachePrivate.h:193
void Clear()
Definition D3D12StateCachePrivate.h:178
FD3D12ConstantBufferCache()
Definition D3D12StateCachePrivate.h:173
D3D12_GPU_VIRTUAL_ADDRESS CurrentGPUVirtualAddress[SF_NumStandardFrequencies][MAX_CBS]
Definition D3D12StateCachePrivate.h:192
Definition D3D12Descriptors.h:95
Definition D3D12PipelineState.h:394
FORCEINLINE FD3D12PixelShader * GetPixelShader() const
Definition D3D12PipelineState.h:400
FORCEINLINE FD3D12AmplificationShader * GetAmplificationShader() const
Definition D3D12PipelineState.h:402
FORCEINLINE FD3D12GeometryShader * GetGeometryShader() const
Definition D3D12PipelineState.h:403
FORCEINLINE FD3D12MeshShader * GetMeshShader() const
Definition D3D12PipelineState.h:401
FORCEINLINE FD3D12VertexShader * GetVertexShader() const
Definition D3D12PipelineState.h:399
Definition D3D12StateCachePrivate.h:101
void Clear()
Definition D3D12StateCachePrivate.h:107
D3D12_INDEX_BUFFER_VIEW CurrentIndexBufferView
Definition D3D12StateCachePrivate.h:112
FD3D12IndexBufferCache()
Definition D3D12StateCachePrivate.h:102
Definition D3D12PipelineState.h:300
Definition D3D12StateCachePrivate.h:117
void Dirty(EShaderFrequency ShaderFrequency, const ResourceSlotMask &SlotMask=-1)
Definition D3D12StateCachePrivate.h:139
void DirtyAll(const ResourceSlotMask &SlotMask=-1)
Definition D3D12StateCachePrivate.h:162
static void CleanSlots(ResourceSlotMask &SlotMask, uint32 NumSlots)
Definition D3D12StateCachePrivate.h:123
static void CleanSlot(ResourceSlotMask &SlotMask, uint32 SlotIndex)
Definition D3D12StateCachePrivate.h:118
void DirtyCompute(const ResourceSlotMask &SlotMask=-1)
Definition D3D12StateCachePrivate.h:156
ResourceSlotMask DirtySlotMask[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:168
static void DirtySlot(ResourceSlotMask &SlotMask, uint32 SlotIndex)
Definition D3D12StateCachePrivate.h:128
static bool IsSlotDirty(const ResourceSlotMask &SlotMask, uint32 SlotIndex)
Definition D3D12StateCachePrivate.h:133
void DirtyGraphics(const ResourceSlotMask &SlotMask=-1)
Definition D3D12StateCachePrivate.h:146
Definition D3D12StateCachePrivate.h:257
FD3D12SamplerState * States[SF_NumStandardFrequencies][MAX_SAMPLERS]
Definition D3D12StateCachePrivate.h:270
FD3D12SamplerStateCache()
Definition D3D12StateCachePrivate.h:258
void Clear()
Definition D3D12StateCachePrivate.h:263
Definition D3D12Shader.h:69
Definition D3D12StateCachePrivate.h:197
int32 MaxBoundIndex[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:228
void Clear()
Definition D3D12StateCachePrivate.h:203
FD3D12ShaderResourceViewCache()
Definition D3D12StateCachePrivate.h:198
FD3D12Resource * Resources[SF_NumStandardFrequencies][MAX_SRVS]
Definition D3D12StateCachePrivate.h:225
SRVSlotMask BoundMask[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:227
FD3D12ShaderResourceView * Views[SF_NumStandardFrequencies][MAX_SRVS]
Definition D3D12StateCachePrivate.h:224
Definition D3D12StateCachePrivate.h:232
FD3D12Resource * Resources[SF_NumStandardFrequencies][MAX_UAVS]
Definition D3D12StateCachePrivate.h:252
void Clear()
Definition D3D12StateCachePrivate.h:238
FD3D12UnorderedAccessViewCache()
Definition D3D12StateCachePrivate.h:233
uint32 StartSlot[SF_NumStandardFrequencies]
Definition D3D12StateCachePrivate.h:253
FD3D12UnorderedAccessView * Views[SF_NumStandardFrequencies][MAX_UAVS]
Definition D3D12StateCachePrivate.h:251
Definition D3D12StateCachePrivate.h:78
D3D12_VERTEX_BUFFER_VIEW CurrentVertexBufferViews[MAX_VBS]
Definition D3D12StateCachePrivate.h:93
FD3D12VertexBufferCache()
Definition D3D12StateCachePrivate.h:79
VBSlotMask BoundVBMask
Definition D3D12StateCachePrivate.h:97
int32 MaxBoundVertexBufferIndex
Definition D3D12StateCachePrivate.h:96
FD3D12ResourceLocation * CurrentVertexBufferResources[MAX_VBS]
Definition D3D12StateCachePrivate.h:94
FD3D12Resource * Resources[MAX_VBS]
Definition D3D12StateCachePrivate.h:95
void Clear()
Definition D3D12StateCachePrivate.h:84
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition UnrealMemory.h:119
Definition MultiGPU.h:33