16#define D3D11_ALLOW_STATE_CACHE 1
20#define D3D11_STATE_CACHE_RUNTIME_TOGGLE 0
25#ifndef D3D11_STATE_CACHE_DEBUG
26#define D3D11_STATE_CACHE_DEBUG 0
34#define D3D11_STATE_CACHE_INLINE FORCEINLINE
39#if D3D11_ALLOW_STATE_CACHE && D3D11_STATE_CACHE_DEBUG && DO_CHECK
40 #define D3D11_STATE_CACHE_VERIFY(...) VerifyCacheState()
41 #define D3D11_STATE_CACHE_VERIFY_PRE(...) VerifyCacheStatePre()
42 #define D3D11_STATE_CACHE_VERIFY_POST(...) VerifyCacheStatePost()
44 #define D3D11_STATE_CACHE_VERIFY(...)
45 #define D3D11_STATE_CACHE_VERIFY_PRE(...)
46 #define D3D11_STATE_CACHE_VERIFY_POST(...)
49#if D3D11_ALLOW_STATE_CACHE && D3D11_STATE_CACHE_RUNTIME_TOGGLE
50extern bool GD3D11SkipStateCaching;
52static const bool GD3D11SkipStateCaching =
false;
68#if D3D11_ALLOW_STATE_CACHE
131 template <EShaderFrequency ShaderFrequency>
136 switch (ShaderFrequency)
145 template <EShaderFrequency ShaderFrequency>
149 switch (ShaderFrequency)
158 template <EShaderFrequency ShaderFrequency>
162 switch (ShaderFrequency)
173#if D3D11_ALLOW_STATE_CACHE
189 template <EShaderFrequency ShaderFrequency>
192#if D3D11_ALLOW_STATE_CACHE
216#if D3D11_ALLOW_STATE_CACHE
233 template <EShaderFrequency ShaderFrequency>
236#if D3D11_ALLOW_STATE_CACHE
251 template <EShaderFrequency ShaderFrequency>
254#if D3D11_ALLOW_STATE_CACHE
259 switch (ShaderFrequency)
268 template <EShaderFrequency ShaderFrequency>
276#if D3D11_ALLOW_STATE_CACHE
292#if D3D11_ALLOW_STATE_CACHE
308#if D3D11_ALLOW_STATE_CACHE
319#if D3D11_ALLOW_STATE_CACHE
343 template <EShaderFrequency ShaderFrequency>
349 template <EShaderFrequency ShaderFrequency>
352#if D3D11_ALLOW_STATE_CACHE
370#if D3D11_ALLOW_STATE_CACHE
385#if D3D11_ALLOW_STATE_CACHE
402#if D3D11_ALLOW_STATE_CACHE
418#if D3D11_ALLOW_STATE_CACHE
434#if D3D11_ALLOW_STATE_CACHE
449#if D3D11_ALLOW_STATE_CACHE
464#if D3D11_ALLOW_STATE_CACHE
477#if D3D11_ALLOW_STATE_CACHE
492#if D3D11_ALLOW_STATE_CACHE
505#if D3D11_ALLOW_STATE_CACHE
520#if D3D11_ALLOW_STATE_CACHE
533#if D3D11_ALLOW_STATE_CACHE
548#if D3D11_ALLOW_STATE_CACHE
566#if D3D11_ALLOW_STATE_CACHE
599#if D3D11_ALLOW_STATE_CACHE
622#if D3D11_ALLOW_STATE_CACHE
645#if D3D11_ALLOW_STATE_CACHE && D3D11_STATE_CACHE_DEBUG
648 template <EShaderFrequency ShaderFrequency>
651 template <EShaderFrequency ShaderFrequency>
654 template <EShaderFrequency ShaderFrequency>
#define check(expr)
Definition AssertionMacros.h:314
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define CA_SUPPRESS(WarningNumber)
Definition CoreMiscDefines.h:125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define D3D11_STATE_CACHE_VERIFY(...)
Definition D3D11StateCachePrivate.h:44
#define D3D11_STATE_CACHE_INLINE
Definition D3D11StateCachePrivate.h:34
#define D3D11_STATE_CACHE_VERIFY_POST(...)
Definition D3D11StateCachePrivate.h:46
#define D3D11_STATE_CACHE_VERIFY_PRE(...)
Definition D3D11StateCachePrivate.h:45
@ SF_Compute
Definition RHIDefinitions.h:208
@ SF_Vertex
Definition RHIDefinitions.h:203
@ SF_Geometry
Definition RHIDefinitions.h:207
@ SF_Pixel
Definition RHIDefinitions.h:206
@ SF_NumStandardFrequencies
Definition RHIDefinitions.h:222
@ MaxVertexElementCount
Definition RHIDefinitions.h:276
uint32 Offset
Definition VulkanMemory.cpp:4033
Definition D3D11StateCachePrivate.h:59
D3D11_STATE_CACHE_INLINE void SetSamplerState(ID3D11SamplerState *SamplerState, uint32 SamplerIndex)
Definition D3D11StateCachePrivate.h:344
virtual void ClearState()
Definition D3D11StateCache.cpp:263
D3D11_STATE_CACHE_INLINE void SetRasterizerState(ID3D11RasterizerState *State)
Definition D3D11StateCachePrivate.h:368
D3D11_STATE_CACHE_INLINE void SetPixelShader(ID3D11PixelShader *Shader)
Definition D3D11StateCachePrivate.h:503
D3D11_STATE_CACHE_INLINE void SetComputeShader(ID3D11ComputeShader *Shader)
Definition D3D11StateCachePrivate.h:531
D3D11_STATE_CACHE_INLINE void GetPixelShader(ID3D11PixelShader **PixelShader)
Definition D3D11StateCachePrivate.h:518
uint32 CurrentIndexOffset
Definition D3D11StateCachePrivate.h:106
float DepthBoundsMax
Definition D3D11StateCachePrivate.h:63
D3D11_STATE_CACHE_INLINE void InternalSetSamplerState(uint32 SamplerIndex, ID3D11SamplerState *&SamplerState)
Definition D3D11StateCachePrivate.h:146
D3D11_STATE_CACHE_INLINE void SetStencilRef(uint32 RefStencil)
Definition D3D11StateCachePrivate.h:432
D3D11_STATE_CACHE_INLINE void SetVertexShader(ID3D11VertexShader *Shader)
Definition D3D11StateCachePrivate.h:447
D3D11_STATE_CACHE_INLINE void InternalSetSamplerState(ID3D11SamplerState *SamplerState, uint32 SamplerIndex)
Definition D3D11StateCachePrivate.h:234
uint16 StreamStrides[MaxVertexElementCount]
Definition D3D11StateCachePrivate.h:114
ID3D11DeviceContext * Direct3DDeviceIMContext
Definition D3D11StateCachePrivate.h:66
ID3D11RasterizerState * CurrentRasterizerState
Definition D3D11StateCachePrivate.h:73
float CurrentBlendFactor[4]
Definition D3D11StateCachePrivate.h:86
D3D11_STATE_CACHE_INLINE void SetInputLayout(ID3D11InputLayout *InputLayout)
Definition D3D11StateCachePrivate.h:564
D3D11_STATE_CACHE_INLINE void GetViewport(D3D11_VIEWPORT *Viewport)
Definition D3D11StateCachePrivate.h:306
D3D11_STATE_CACHE_INLINE void SetStreamSource(ID3D11Buffer *VertexBuffer, uint32 StreamIndex, uint32 Stride, uint32 Offset)
Definition D3D11StateCachePrivate.h:579
D3D11_STATE_CACHE_INLINE void GetVertexShader(ID3D11VertexShader **VertexShader)
Definition D3D11StateCachePrivate.h:462
ID3D11PixelShader * CurrentPixelShader
Definition D3D11StateCachePrivate.h:82
bool bAlwaysSetIndexBuffers
Definition D3D11StateCachePrivate.h:127
D3D11_STATE_CACHE_INLINE void SetStreamStrides(const uint16 *InStreamStrides)
Definition D3D11StateCachePrivate.h:559
D3D11_STATE_CACHE_INLINE void SetStreamSource(ID3D11Buffer *VertexBuffer, uint32 StreamIndex, uint32 Offset)
Definition D3D11StateCachePrivate.h:585
uint32 CurrentReferenceStencil
Definition D3D11StateCachePrivate.h:76
uint32 CurrentBlendSampleMask
Definition D3D11StateCachePrivate.h:87
D3D11_STATE_CACHE_INLINE void InternalSetShaderResourceView(uint32 ResourceIndex, ID3D11ShaderResourceView *&SRV)
Definition D3D11StateCachePrivate.h:132
D3D11_STATE_CACHE_INLINE void SetViewport(D3D11_VIEWPORT Viewport)
Definition D3D11StateCachePrivate.h:274
D3D11_STATE_CACHE_INLINE void GetGeometryShader(ID3D11GeometryShader **GeometryShader)
Definition D3D11StateCachePrivate.h:490
virtual D3D11_STATE_CACHE_INLINE void SetContext(ID3D11DeviceContext *InDeviceContext)
Definition D3D11StateCachePrivate.h:631
ID3D11ComputeShader * CurrentComputeShader
Definition D3D11StateCachePrivate.h:83
D3D11_STATE_CACHE_INLINE void GetViewports(uint32 *Count, D3D11_VIEWPORT *Viewports)
Definition D3D11StateCachePrivate.h:317
D3D11_VIEWPORT CurrentViewport[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]
Definition D3D11StateCachePrivate.h:92
ID3D11GeometryShader * CurrentGeometryShader
Definition D3D11StateCachePrivate.h:81
virtual ~FD3D11StateCacheBase()
Definition D3D11StateCachePrivate.h:627
ID3D11DepthStencilState * CurrentDepthStencilState
Definition D3D11StateCachePrivate.h:77
ID3D11ShaderResourceView * CurrentShaderResourceViews[SF_NumStandardFrequencies][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]
Definition D3D11StateCachePrivate.h:70
float DepthBoundsMin
Definition D3D11StateCachePrivate.h:62
D3D11_STATE_CACHE_INLINE void GetComputeShader(ID3D11ComputeShader **ComputeShader)
Definition D3D11StateCachePrivate.h:546
bool bDepthBoundsEnabled
Definition D3D11StateCachePrivate.h:61
struct FD3D11StateCacheBase::FD3D11ConstantBufferState CurrentConstantBuffers[SF_NumStandardFrequencies][D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]
D3D11_STATE_CACHE_INLINE void SetBlendState(ID3D11BlendState *State, const float BlendFactor[4], uint32 SampleMask)
Definition D3D11StateCachePrivate.h:383
ID3D11SamplerState * CurrentSamplerStates[SF_NumStandardFrequencies][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]
Definition D3D11StateCachePrivate.h:117
D3D11_STATE_CACHE_INLINE void SetViewports(uint32 Count, D3D11_VIEWPORT *Viewports)
Definition D3D11StateCachePrivate.h:290
D3D11_STATE_CACHE_INLINE void SetIndexBuffer(ID3D11Buffer *IndexBuffer, DXGI_FORMAT Format, uint32 Offset)
Definition D3D11StateCachePrivate.h:592
D3D11_STATE_CACHE_INLINE void SetConstantBuffer(ID3D11Buffer *ConstantBuffer, uint32 SlotIndex)
Definition D3D11StateCachePrivate.h:350
DXGI_FORMAT CurrentIndexFormat
Definition D3D11StateCachePrivate.h:105
D3D11_STATE_CACHE_INLINE void SetShaderResourceView(ID3D11ShaderResourceView *SRV, uint32 ResourceIndex)
Definition D3D11StateCachePrivate.h:269
D3D11_STATE_CACHE_INLINE void SetDepthStencilState(ID3D11DepthStencilState *State, uint32 RefStencil)
Definition D3D11StateCachePrivate.h:416
D3D11_STATE_CACHE_INLINE void SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology)
Definition D3D11StateCachePrivate.h:597
D3D11_STATE_CACHE_INLINE void InternalSetStreamSource(ID3D11Buffer *VertexBuffer, uint32 StreamIndex, uint32 Stride, uint32 Offset)
Definition D3D11StateCachePrivate.h:214
D3D11_STATE_CACHE_INLINE void InternalSetShaderResourceView(ID3D11ShaderResourceView *&SRV, uint32 ResourceIndex)
Definition D3D11StateCachePrivate.h:190
ID3D11BlendState * CurrentBlendState
Definition D3D11StateCachePrivate.h:88
ID3D11VertexShader * CurrentVertexShader
Definition D3D11StateCachePrivate.h:80
D3D11_STATE_CACHE_INLINE void InternalSetSetConstantBuffer(uint32 SlotIndex, ID3D11Buffer *&ConstantBuffer)
Definition D3D11StateCachePrivate.h:159
ID3D11InputLayout * CurrentInputLayout
Definition D3D11StateCachePrivate.h:112
D3D11_PRIMITIVE_TOPOLOGY CurrentPrimitiveTopology
Definition D3D11StateCachePrivate.h:109
D3D11_STATE_CACHE_INLINE void InternalSetIndexBuffer(ID3D11Buffer *IndexBuffer, DXGI_FORMAT Format, uint32 Offset)
Definition D3D11StateCachePrivate.h:171
struct FD3D11StateCacheBase::FD3D11VertexBufferState CurrentVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
ID3D11Buffer * CurrentIndexBuffer
Definition D3D11StateCachePrivate.h:104
D3D11_STATE_CACHE_INLINE void SetGeometryShader(ID3D11GeometryShader *Shader)
Definition D3D11StateCachePrivate.h:475
uint32 CurrentNumberOfViewports
Definition D3D11StateCachePrivate.h:91
void Init(ID3D11DeviceContext *InDeviceContext, bool bInAlwaysSetIndexBuffers=false)
Definition D3D11StateCachePrivate.h:618
D3D11_STATE_CACHE_INLINE void ClearConstantBuffers()
Definition D3D11StateCachePrivate.h:252
D3D11_STATE_CACHE_INLINE void SetBlendFactor(const float BlendFactor[4], uint32 SampleMask)
Definition D3D11StateCachePrivate.h:400
FD3D11StateCacheBase()
Definition D3D11StateCachePrivate.h:612
Definition D3D11StateCachePrivate.h:121
ID3D11Buffer * Buffer
Definition D3D11StateCachePrivate.h:122
uint32 NumConstants
Definition D3D11StateCachePrivate.h:124
uint32 FirstConstant
Definition D3D11StateCachePrivate.h:123
Definition D3D11StateCachePrivate.h:97
uint32 Stride
Definition D3D11StateCachePrivate.h:99
uint32 Offset
Definition D3D11StateCachePrivate.h:100
ID3D11Buffer * VertexBuffer
Definition D3D11StateCachePrivate.h:98
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
static UE_FORCEINLINE_HINT int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
Definition UnrealMemory.h:114
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