1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
4 #include "../DeviceObjects.h"
5 #include "../../../Common/ReverseDepth.h"
7 #include "DeviceCommandListCommon_D3D11.h"
8 #include "DeviceObjects_D3D11.h"
9 #include "DeviceResourceSet_D3D11.h"
10 #include "DevicePSO_D3D11.h"
12 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14 #if !defined(CRY_PLATFORM_ORBIS)
16 CDeviceTimestampGroup::CDeviceTimestampGroup()
18 , m_pDisjointQuery(nullptr)
23 m_timestampQueries
.fill(nullptr);
27 CDeviceTimestampGroup::~CDeviceTimestampGroup()
29 SAFE_RELEASE(m_pDisjointQuery
);
30 for (uint32 i
= 0; i
< m_timestampQueries
.size(); i
++)
32 SAFE_RELEASE(m_timestampQueries
[i
]);
36 void CDeviceTimestampGroup::Init()
38 D3D11_QUERY_DESC queryTimestampDesc
= { D3D11_QUERY_TIMESTAMP
, 0 };
39 D3D11_QUERY_DESC queryDisjointDesc
= { D3D11_QUERY_TIMESTAMP_DISJOINT
, 0 };
41 for (uint32 i
= 0; i
< m_timestampQueries
.size(); i
++)
43 gcpRendD3D
->GetDevice().CreateQuery(&queryTimestampDesc
, &m_timestampQueries
[i
]);
45 gcpRendD3D
->GetDevice().CreateQuery(&queryDisjointDesc
, &m_pDisjointQuery
);
48 void CDeviceTimestampGroup::BeginMeasurement()
55 gcpRendD3D
->GetDeviceContext().Begin(m_pDisjointQuery
);
58 void CDeviceTimestampGroup::EndMeasurement()
60 gcpRendD3D
->GetDeviceContext().End(m_pDisjointQuery
);
65 uint32
CDeviceTimestampGroup::IssueTimestamp(CDeviceCommandList
* pCommandList
)
67 assert(m_numTimestamps
< m_timestampQueries
.size());
68 gcpRendD3D
->GetDeviceContext().End(m_timestampQueries
[m_numTimestamps
]);
69 m_timeValues
[m_numTimestamps
] = 0;
71 return (m_numTimestamps
+ 1) < m_timestampQueries
.size() ? m_numTimestamps
++ : m_numTimestamps
;
74 bool CDeviceTimestampGroup::ResolveTimestamps()
81 // Don't ask twice (API violation)
84 D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointData
;
85 if (gcpRendD3D
->GetDeviceContext().GetData(m_pDisjointQuery
, &disjointData
, m_pDisjointQuery
->GetDataSize(), 0) == S_OK
)
87 m_frequency
= disjointData
.Frequency
;
96 int i
= m_numTimestamps
;
99 // Don't ask twice (API violation)
100 if (!m_timeValues
[i
])
102 if (gcpRendD3D
->GetDeviceContext().GetData(m_timestampQueries
[i
], &m_timeValues
[i
], m_timestampQueries
[i
]->GetDataSize(), 0) != S_OK
)
110 return m_measured
= true;
117 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
118 CDeviceNvidiaCommandInterfaceImpl
* CDeviceCommandListImpl::GetNvidiaCommandInterfaceImpl()
120 if (gcpRendD3D
->m_bVendorLibInitialized
&& (gRenDev
->GetFeatures() & RFT_HW_NVIDIA
))
122 return reinterpret_cast<CDeviceNvidiaCommandInterfaceImpl
*>(this);
128 void CDeviceCommandListImpl::SetProfilerMarker(const char* label
)
130 PROFILE_LABEL_GPU(label
);
133 void CDeviceCommandListImpl::BeginProfilerEvent(const char* label
)
135 PROFILE_LABEL_PUSH_GPU(label
);
138 void CDeviceCommandListImpl::EndProfilerEvent(const char* label
)
140 PROFILE_LABEL_POP_GPU(label
);
143 void CDeviceCommandListImpl::ClearStateImpl(bool bOutputMergerOnly
) const
145 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
147 if (rd
->GetDeviceContext().IsValid())
149 D3DDepthSurface
* pDSV
= 0;
150 D3DSurface
* pRTVs
[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
] = { 0 };
152 if (bOutputMergerOnly
)
153 rd
->GetDeviceContext().OMSetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT
, pRTVs
, pDSV
);
155 rd
->GetDeviceContext().ClearState();
158 rd
->m_DevMan
.ClearState();
161 void CDeviceCommandListImpl::ResetImpl()
163 const uint8 InvalidShaderPointer
= (uint8
)(uint64
)CDeviceResourceSet_DX11::InvalidPointer
;
164 CRY_ASSERT((InvalidShaderPointer
& 0x1) != 0);
166 memset(m_sharedState
.shader
, InvalidShaderPointer
, sizeof(m_sharedState
.shader
));
167 memset(m_sharedState
.shaderResourceView
, InvalidShaderPointer
, sizeof(m_sharedState
.shaderResourceView
));
168 memset(m_sharedState
.samplerState
, InvalidShaderPointer
, sizeof(m_sharedState
.samplerState
));
169 memset(m_sharedState
.constantBuffer
, InvalidShaderPointer
, sizeof(m_sharedState
.constantBuffer
));
170 m_sharedState
.validShaderStages
= EShaderStage_All
;
172 m_sharedState
.numSRVs
.fill(0);
173 m_sharedState
.numSamplers
.fill(0);
175 UINT_PTR invalidPtr
= UINT_PTR(~0u);
176 m_graphicsState
.custom
.depthStencilState
= nullptr;
177 m_graphicsState
.custom
.rasterizerState
= nullptr;
178 m_graphicsState
.custom
.rasterizerStateIndex
= 0;
179 m_graphicsState
.custom
.blendState
= nullptr;
180 m_graphicsState
.custom
.inputLayout
= reinterpret_cast<ID3D11InputLayout
*>(invalidPtr
);
181 m_graphicsState
.custom
.topology
= D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED
;
182 m_graphicsState
.custom
.bDepthStencilStateDirty
= true;
183 m_graphicsState
.custom
.depthConstBias
= 0.0f
;
184 m_graphicsState
.custom
.depthSlopeBias
= 0.0f
;
185 m_graphicsState
.custom
.depthBiasClamp
= 0.0f
;
186 m_graphicsState
.custom
.bRasterizerStateDirty
= true;
188 m_computeState
.custom
.boundUAVs
= 0;
191 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
194 (1 << eHWSC_Vertex
) == EShaderStage_Vertex
&&
195 (1 << eHWSC_Pixel
) == EShaderStage_Pixel
&&
196 (1 << eHWSC_Geometry
) == EShaderStage_Geometry
&&
197 (1 << eHWSC_Domain
) == EShaderStage_Domain
&&
198 (1 << eHWSC_Hull
) == EShaderStage_Hull
,
199 "EShaderStage should have bits corresponding with EHWShaderClass");
202 eHWSC_Vertex
== CSubmissionQueue_DX11::TYPE_VS
&&
203 eHWSC_Pixel
== CSubmissionQueue_DX11::TYPE_PS
&&
204 eHWSC_Geometry
== CSubmissionQueue_DX11::TYPE_GS
&&
205 eHWSC_Domain
== CSubmissionQueue_DX11::TYPE_DS
&&
206 eHWSC_Hull
== CSubmissionQueue_DX11::TYPE_HS
&&
207 eHWSC_Compute
== CSubmissionQueue_DX11::TYPE_CS
,
208 "SHADER_TYPE enumeration should match EHWShaderClass for performance reasons");
210 static inline void BindShader(EHWShaderClass shaderClass
, ID3D11Resource
* pBin
)
212 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
213 rd
->m_DevMan
.BindShader(static_cast<CSubmissionQueue_DX11::SHADER_TYPE
>(shaderClass
), pBin
);
216 static inline void BindSRV(EHWShaderClass shaderClass
, ID3D11ShaderResourceView
* pSrv
, uint32 slot
)
218 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
219 rd
->m_DevMan
.BindSRV(static_cast<CSubmissionQueue_DX11::SHADER_TYPE
>(shaderClass
), pSrv
, slot
);
222 static inline void BindUAV(EHWShaderClass shaderClass
, ID3D11UnorderedAccessView
* pUAV
, uint32 slot
)
224 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
225 rd
->m_DevMan
.BindUAV(static_cast<CSubmissionQueue_DX11::SHADER_TYPE
>(shaderClass
), pUAV
, 0, slot
);
228 static inline void BindSampler(EHWShaderClass shaderClass
, ID3D11SamplerState
* pSamplerState
, uint32 slot
)
230 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
231 rd
->m_DevMan
.BindSampler(static_cast<CSubmissionQueue_DX11::SHADER_TYPE
>(shaderClass
), pSamplerState
, slot
);
234 static inline void BindConstantBuffer(EHWShaderClass shaderClass
, D3DBuffer
* pBuffer
, EConstantBufferShaderSlot slot
)
236 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
237 rd
->m_DevMan
.BindConstantBuffer(static_cast<CSubmissionQueue_DX11::SHADER_TYPE
>(shaderClass
), pBuffer
, slot
);
240 static inline void BindConstantBuffer(EHWShaderClass shaderClass
, D3DBuffer
* pBuffer
, EConstantBufferShaderSlot slot
, uint32 offset
, uint32 size
)
242 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
243 rd
->m_DevMan
.BindConstantBuffer(static_cast<CSubmissionQueue_DX11::SHADER_TYPE
>(shaderClass
), pBuffer
, slot
, offset
, size
);
247 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
248 void CDeviceGraphicsCommandInterfaceImpl::BeginRenderPassImpl(const CDeviceRenderPass
& renderPass
, const D3DRectangle
& renderArea
)
250 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
251 rd
->GetDeviceContext().OMSetRenderTargets(renderPass
.m_RenderTargetCount
, renderPass
.m_RenderTargetViews
.data(), renderPass
.m_pDepthStencilView
);
254 void CDeviceGraphicsCommandInterfaceImpl::SetViewportsImpl(uint32 vpCount
, const D3DViewPort
* pViewports
)
256 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
257 rd
->GetDeviceContext().RSSetViewports(vpCount
, pViewports
);
260 void CDeviceGraphicsCommandInterfaceImpl::SetScissorRectsImpl(uint32 rcCount
, const D3DRectangle
* pRects
)
262 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
263 rd
->GetDeviceContext().RSSetScissorRects(rcCount
, pRects
);
266 void CDeviceGraphicsCommandInterfaceImpl::SetPipelineStateImpl(const CDeviceGraphicsPSO
* devicePSO
)
268 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
269 const CDeviceGraphicsPSO_DX11
* pDevicePSO
= reinterpret_cast<const CDeviceGraphicsPSO_DX11
*>(devicePSO
);
271 // RasterState, BlendState
272 if (m_graphicsState
.custom
.blendState
.Set(pDevicePSO
->m_pBlendState
.get()))
274 rd
->m_DevMan
.SetBlendState(pDevicePSO
->m_pBlendState
, NULL
, 0xffffffff);
277 // Rasterizer state: NOTE - we don't know the final depth bias values yet so only mark dirty here and set in actual draw call
278 if (m_graphicsState
.custom
.rasterizerState
.Set(pDevicePSO
->m_pRasterizerState
.get()))
280 m_graphicsState
.custom
.rasterizerStateIndex
= pDevicePSO
->m_RasterizerStateIndex
;
281 m_graphicsState
.custom
.bRasterizerStateDirty
= true;
284 // Depth stencil state: NOTE - we don't know the final stencil ref value yet so only mark dirty here and set in actual draw call
285 if (m_graphicsState
.custom
.depthStencilState
.Set(pDevicePSO
->m_pDepthStencilState
.get()))
287 m_graphicsState
.custom
.bDepthStencilStateDirty
= true;
290 // input layout and topology
291 if (m_graphicsState
.custom
.inputLayout
.Set(pDevicePSO
->m_pInputLayout
.get())) rd
->m_DevMan
.BindVtxDecl(pDevicePSO
->m_pInputLayout
);
292 if (m_graphicsState
.custom
.topology
.Set(pDevicePSO
->m_PrimitiveTopology
)) rd
->m_DevMan
.BindTopology(pDevicePSO
->m_PrimitiveTopology
);
294 // Shaders and update valid shader mask
295 m_sharedState
.validShaderStages
= EShaderStage_None
;
297 const std::array
<void*, eHWSC_Num
>& shaders
= pDevicePSO
->m_pDeviceShaders
;
298 for (EHWShaderClass shaderClass
= eHWSC_Vertex
; shaderClass
!= eHWSC_NumGfx
; shaderClass
= EHWShaderClass(shaderClass
+ 1))
300 m_sharedState
.validShaderStages
|= SHADERSTAGE_FROM_SHADERCLASS_CONDITIONAL(shaderClass
, shaders
[shaderClass
] ? 1 : 0);
302 if (m_sharedState
.shader
[shaderClass
].Set(shaders
[shaderClass
]))
304 BindShader(shaderClass
, (ID3D11Resource
*)shaders
[shaderClass
]);
308 m_sharedState
.srvs
= pDevicePSO
->m_SRVs
;
309 m_sharedState
.samplers
= pDevicePSO
->m_Samplers
;
311 m_sharedState
.numSRVs
= pDevicePSO
->m_NumSRVs
;
312 m_sharedState
.numSamplers
= pDevicePSO
->m_NumSamplers
;
315 void CDeviceGraphicsCommandInterfaceImpl::SetResourcesImpl(uint32 bindSlot
, const CDeviceResourceSet
* pResources
)
317 auto pResourcesDX11
= reinterpret_cast<const CDeviceResourceSet_DX11
*>(pResources
);
319 if (pResources
->GetFlags() & CDeviceResourceSet::EFlags_ForceSetAllState
)
321 SetResources_All(pResourcesDX11
);
325 SetResources_RequestedByShaderOnly(pResourcesDX11
);
329 void CDeviceGraphicsCommandInterfaceImpl::SetResources_RequestedByShaderOnly(const CDeviceResourceSet
* pResources
)
331 auto pResourcesDX11
= reinterpret_cast<const CDeviceResourceSet_DX11
*>(pResources
);
333 // Shader stages are ordered by usage-frequency and loop exists according to usage-frequency (VS+PS fast, etc.)
334 int validShaderStages
= m_sharedState
.validShaderStages
;
335 for (EHWShaderClass shaderClass
= eHWSC_Vertex
; validShaderStages
; shaderClass
= EHWShaderClass(shaderClass
+ 1), validShaderStages
>>= 1)
337 if (validShaderStages
& 1)
340 // if (!pResourcesDX11->compiledSRVs.empty()) // currently this is always the case
342 for (int i
= 0; i
< m_sharedState
.numSRVs
[shaderClass
]; ++i
)
344 uint8 srvSlot
= m_sharedState
.srvs
[shaderClass
][i
];
345 ID3D11ShaderResourceView
* pSrv
= pResourcesDX11
->compiledSRVs
[shaderClass
][srvSlot
];
347 if (pSrv
!= CDeviceResourceSet_DX11::InvalidPointer
)
349 if (m_sharedState
.shaderResourceView
[shaderClass
][srvSlot
].Set(pSrv
))
351 BindSRV(shaderClass
, pSrv
, srvSlot
);
358 // if (!pResourcesDX11->compiledSamplers.empty()) // currently this is always the case
360 for (int i
= 0; i
< m_sharedState
.numSamplers
[shaderClass
]; ++i
)
362 uint8 samplerSlot
= m_sharedState
.samplers
[shaderClass
][i
];
363 ID3D11SamplerState
* pSamplerState
= pResourcesDX11
->compiledSamplers
[shaderClass
][samplerSlot
];
365 if (pSamplerState
!= CDeviceResourceSet_DX11::InvalidPointer
)
367 if (m_sharedState
.samplerState
[shaderClass
][samplerSlot
].Set(pSamplerState
))
369 BindSampler(shaderClass
, pSamplerState
, samplerSlot
);
375 // Bind constant buffers
376 for (int i
= 0; i
< pResourcesDX11
->numCompiledCBs
[shaderClass
]; ++i
)
378 const CDeviceResourceSet_DX11::SCompiledConstantBuffer
& cb
= pResourcesDX11
->compiledCBs
[shaderClass
][i
];
379 if (m_sharedState
.constantBuffer
[shaderClass
][cb
.slot
].Set(cb
.code
))
381 BindConstantBuffer(shaderClass
, cb
.pBuffer
, cb
.slot
, cb
.offset
, cb
.size
);
388 for (int i
= 0; i
< pResourcesDX11
->numCompiledUAVs
; ++i
)
390 const CDeviceResourceSet_DX11::SCompiledUAV
& uav
= pResourcesDX11
->compiledUAVs
[i
];
391 if (validShaderStages
& uav
.shaderStage
)
393 BindUAV(uav
.shaderStage
, uav
.pUav
, uav
.slot
);
398 void CDeviceGraphicsCommandInterfaceImpl::SetResources_All(const CDeviceResourceSet
* pResources
)
400 auto pResourcesDX11
= reinterpret_cast<const CDeviceResourceSet_DX11
*>(pResources
);
402 for (EHWShaderClass shaderClass
= eHWSC_Vertex
; shaderClass
!= eHWSC_NumGfx
; shaderClass
= EHWShaderClass(shaderClass
+ 1))
405 for (int slot
= pResourcesDX11
->firstCompiledSRVs
[shaderClass
]; slot
<= pResourcesDX11
->lastCompiledSRVs
[shaderClass
]; ++slot
)
407 ID3D11ShaderResourceView
* pSrv
= pResourcesDX11
->compiledSRVs
[shaderClass
][slot
];
409 if (pSrv
!= CDeviceResourceSet_DX11::InvalidPointer
)
411 if (m_sharedState
.shaderResourceView
[shaderClass
][slot
].Set(pSrv
))
413 BindSRV(shaderClass
, pSrv
, slot
);
419 for (int slot
= pResourcesDX11
->firstCompiledSamplers
[shaderClass
]; slot
<= pResourcesDX11
->lastCompiledSamplers
[shaderClass
]; ++slot
)
421 ID3D11SamplerState
* pSamplerState
= pResourcesDX11
->compiledSamplers
[shaderClass
][slot
];
423 if (pSamplerState
!= CDeviceResourceSet_DX11::InvalidPointer
)
425 if (m_sharedState
.samplerState
[shaderClass
][slot
].Set(pSamplerState
))
427 BindSampler(shaderClass
, pSamplerState
, slot
);
432 // Bind constant buffers
433 for (int i
= 0; i
< pResourcesDX11
->numCompiledCBs
[shaderClass
]; ++i
)
435 const CDeviceResourceSet_DX11::SCompiledConstantBuffer
& cb
= pResourcesDX11
->compiledCBs
[shaderClass
][i
];
436 if (m_sharedState
.constantBuffer
[shaderClass
][cb
.slot
].Set(cb
.code
))
438 BindConstantBuffer(shaderClass
, cb
.pBuffer
, cb
.slot
, cb
.offset
, cb
.size
);
444 for (int i
= 0; i
< pResourcesDX11
->numCompiledUAVs
; ++i
)
446 const CDeviceResourceSet_DX11::SCompiledUAV
& uav
= pResourcesDX11
->compiledUAVs
[i
];
447 BindUAV(uav
.shaderStage
, uav
.pUav
, uav
.slot
);
452 void CDeviceGraphicsCommandInterfaceImpl::ApplyDepthStencilState()
454 if (m_graphicsState
.custom
.bDepthStencilStateDirty
)
456 gcpRendD3D
->m_DevMan
.SetDepthStencilState(m_graphicsState
.custom
.depthStencilState
.cachedValue
, m_graphicsState
.stencilRef
.cachedValue
);
457 m_graphicsState
.custom
.bDepthStencilStateDirty
= false;
461 void CDeviceGraphicsCommandInterfaceImpl::ApplyRasterizerState()
463 if (m_graphicsState
.custom
.bRasterizerStateDirty
)
465 auto pRasterizerState
= m_graphicsState
.custom
.rasterizerState
.cachedValue
;
467 if (m_graphicsState
.custom
.depthConstBias
!= 0.0f
|| m_graphicsState
.custom
.depthSlopeBias
!= 0.0f
)
469 auto rsDesc
= CDeviceStatesManagerDX11::GetInstance()->m_StatesRS
[m_graphicsState
.custom
.rasterizerStateIndex
].Desc
;
470 rsDesc
.DepthBias
= int(m_graphicsState
.custom
.depthConstBias
);
471 rsDesc
.SlopeScaledDepthBias
= m_graphicsState
.custom
.depthSlopeBias
;
472 rsDesc
.DepthBiasClamp
= m_graphicsState
.custom
.depthBiasClamp
;
474 uint32 newRasterizerStateIndex
= CDeviceStatesManagerDX11::GetInstance()->GetOrCreateRasterState(rsDesc
);
475 if (newRasterizerStateIndex
!= uint32(-1))
477 pRasterizerState
= CDeviceStatesManagerDX11::GetInstance()->m_StatesRS
[newRasterizerStateIndex
].pState
;
481 gcpRendD3D
->m_DevMan
.SetRasterState(pRasterizerState
);
482 m_graphicsState
.custom
.bRasterizerStateDirty
= false;
486 void CDeviceGraphicsCommandInterfaceImpl::SetInlineConstantBufferImpl(uint32 bindSlot
, const CConstantBuffer
* pBuffer
, EConstantBufferShaderSlot shaderSlot
, EShaderStage shaderStages
)
488 // Shader stages are ordered by usage-frequency and loop exists according to usage-frequency (VS+PS fast, etc.)
489 int validShaderStages
= shaderStages
;
490 for (EHWShaderClass shaderClass
= eHWSC_Vertex
; validShaderStages
; shaderClass
= EHWShaderClass(shaderClass
+ 1), validShaderStages
>>= 1)
492 if (validShaderStages
& 1)
493 SetInlineConstantBufferImpl(bindSlot
, pBuffer
, shaderSlot
, shaderClass
);
497 void CDeviceGraphicsCommandInterfaceImpl::SetInlineConstantBufferImpl(uint32 bindSlot
, const CConstantBuffer
* pBuffer
, EConstantBufferShaderSlot shaderSlot
, EHWShaderClass shaderClass
)
499 if (m_sharedState
.constantBuffer
[shaderClass
][shaderSlot
].Set(pBuffer
->GetCode()))
501 buffer_size_t offset
, size
;
502 D3DBuffer
* pBufferDX11
= pBuffer
->GetD3D(&offset
, &size
);
504 BindConstantBuffer(shaderClass
, pBufferDX11
, shaderSlot
, offset
, size
);
508 void CDeviceGraphicsCommandInterfaceImpl::SetInlineShaderResourceImpl(uint32 bindSlot
, const CDeviceBuffer
* pBuffer
, EShaderResourceShaderSlot shaderSlot
, EShaderStage shaderStages
, ResourceViewHandle resourceViewID
)
510 // Shader stages are ordered by usage-frequency and loop exists according to usage-frequency (VS+PS fast, etc.)
511 int validShaderStages
= shaderStages
;
512 for (EHWShaderClass shaderClass
= eHWSC_Vertex
; validShaderStages
; shaderClass
= EHWShaderClass(shaderClass
+ 1), validShaderStages
>>= 1)
514 if (validShaderStages
& 1)
515 SetInlineShaderResourceImpl(bindSlot
, pBuffer
, shaderSlot
, shaderClass
, resourceViewID
);
519 void CDeviceGraphicsCommandInterfaceImpl::SetInlineShaderResourceImpl(uint32 bindSlot
, const CDeviceBuffer
* pBuffer
, EShaderResourceShaderSlot shaderSlot
, EHWShaderClass shaderClass
, ResourceViewHandle resourceViewID
)
521 D3DShaderResource
* pBufferViewDX11
= pBuffer
->LookupSRV(resourceViewID
);
523 if (m_sharedState
.shaderResourceView
[shaderClass
][shaderSlot
].Set(pBufferViewDX11
))
525 BindSRV(shaderClass
, pBufferViewDX11
, shaderSlot
);
529 void CDeviceGraphicsCommandInterfaceImpl::SetVertexBuffersImpl(uint32 numStreams
, uint32 lastStreamSlot
, const CDeviceInputStream
* vertexStreams
)
531 for (uint32 s
= 0; s
< numStreams
; ++s
)
533 const CDeviceInputStream
& current
= vertexStreams
[s
];
535 CRY_ASSERT(current
.hStream
!= ~0u);
537 buffer_size_t offset
;
538 D3DBuffer
* buffer
= gcpRendD3D
.m_DevBufMan
.GetD3D(current
.hStream
, &offset
);
540 gcpRendD3D
.m_DevMan
.BindVB(buffer
, current
.nSlot
, offset
, current
.nStride
);
545 void CDeviceGraphicsCommandInterfaceImpl::SetIndexBufferImpl(const CDeviceInputStream
* indexStream
)
547 const CDeviceInputStream
& current
= indexStream
[0];
549 CRY_ASSERT(current
.hStream
!= ~0u);
551 buffer_size_t offset
;
552 D3DBuffer
* buffer
= gcpRendD3D
.m_DevBufMan
.GetD3D(current
.hStream
, &offset
);
554 #if !defined(SUPPORT_FLEXIBLE_INDEXBUFFER)
555 gcpRendD3D
.m_DevMan
.BindIB(buffer
, offset
, DXGI_FORMAT_R16_UINT
);
557 gcpRendD3D
.m_DevMan
.BindIB(buffer
, offset
, (DXGI_FORMAT
)current
.nStride
);
562 void CDeviceGraphicsCommandInterfaceImpl::SetStencilRefImpl(uint8 stencilRefValue
)
564 m_graphicsState
.custom
.bDepthStencilStateDirty
= true;
567 void CDeviceGraphicsCommandInterfaceImpl::SetDepthBiasImpl(float constBias
, float slopeBias
, float biasClamp
)
569 m_graphicsState
.custom
.depthConstBias
= constBias
;
570 m_graphicsState
.custom
.depthSlopeBias
= slopeBias
;
571 m_graphicsState
.custom
.depthBiasClamp
= biasClamp
;
573 m_graphicsState
.custom
.bRasterizerStateDirty
= true;
576 void CDeviceGraphicsCommandInterfaceImpl::DrawImpl(uint32 VertexCountPerInstance
, uint32 InstanceCount
, uint32 StartVertexLocation
, uint32 StartInstanceLocation
)
578 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
580 ApplyDepthStencilState();
581 ApplyRasterizerState();
583 if (InstanceCount
> 1 || StartInstanceLocation
> 0)
585 rd
->m_DevMan
.DrawInstanced(VertexCountPerInstance
, InstanceCount
, StartVertexLocation
, StartInstanceLocation
);
589 rd
->m_DevMan
.Draw(VertexCountPerInstance
, StartVertexLocation
);
593 void CDeviceGraphicsCommandInterfaceImpl::DrawIndexedImpl(uint32 IndexCountPerInstance
, uint32 InstanceCount
, uint32 StartIndexLocation
, int BaseVertexLocation
, uint32 StartInstanceLocation
)
595 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
597 #if !defined(SUPPORT_FLEXIBLE_INDEXBUFFER)
598 STATIC_CHECK(false, "NOT IMPLEMENTED");
601 ApplyDepthStencilState();
602 ApplyRasterizerState();
604 if (InstanceCount
> 1 || StartInstanceLocation
> 0)
606 rd
->m_DevMan
.DrawIndexedInstanced(IndexCountPerInstance
, InstanceCount
, StartIndexLocation
, BaseVertexLocation
, StartInstanceLocation
);
610 rd
->m_DevMan
.DrawIndexed(IndexCountPerInstance
, StartIndexLocation
, BaseVertexLocation
);
614 void CDeviceGraphicsCommandInterfaceImpl::ClearSurfaceImpl(D3DSurface
* pView
, const float color
[4], UINT numRects
, const D3D11_RECT
* pRects
)
616 #if (CRY_RENDERER_DIRECT3D >= 111)
617 gcpRendD3D
->GetDeviceContext().ClearView(pView
, color
, numRects
, pRects
);
619 CRY_ASSERT(numRects
== 0); // not supported on dx11
620 gcpRendD3D
->GetDeviceContext().ClearRenderTargetView(pView
, color
);
624 void CDeviceGraphicsCommandInterfaceImpl::ClearSurfaceImpl(D3DDepthSurface
* pView
, int clearFlags
, float depth
, uint8 stencil
, uint32 numRects
, const D3D11_RECT
* pRects
)
626 CRY_ASSERT(numRects
== 0); // not supported on dx11
627 gcpRendD3D
->GetDeviceContext().ClearDepthStencilView(pView
, D3D11_CLEAR_FLAG(clearFlags
), depth
, stencil
);
630 void CDeviceGraphicsCommandInterfaceImpl::DiscardContentsImpl(D3DResource
* pResource
, uint32 numRects
, const D3D11_RECT
* pRects
)
632 #if (CRY_RENDERER_DIRECT3D >= 111)
633 CRY_ASSERT(numRects
== 0); // not supported on dx11.1
634 gcpRendD3D
->GetDeviceContext().DiscardResource(pResource
);
638 void CDeviceGraphicsCommandInterfaceImpl::DiscardContentsImpl(D3DBaseView
* pView
, uint32 numRects
, const D3D11_RECT
* pRects
)
640 #if (CRY_RENDERER_DIRECT3D >= 111)
642 gcpRendD3D
->GetDeviceContext().DiscardView1(pView
, numRects
, pRects
);
644 gcpRendD3D
->GetDeviceContext().DiscardView(pView
);
648 void CDeviceGraphicsCommandInterfaceImpl::BeginOcclusionQueryImpl(D3DOcclusionQuery
* pQuery
)
650 gcpRendD3D
->GetDeviceContext().Begin(pQuery
);
653 void CDeviceGraphicsCommandInterfaceImpl::EndOcclusionQueryImpl(D3DOcclusionQuery
* pQuery
)
655 gcpRendD3D
->GetDeviceContext().End(pQuery
);
658 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
659 void CDeviceComputeCommandInterfaceImpl::SetPipelineStateImpl(const CDeviceComputePSO
* pDevicePSO
)
661 const CDeviceComputePSO_DX11
* pDevicePsoDX11
= reinterpret_cast<const CDeviceComputePSO_DX11
*>(pDevicePSO
);
664 const std::array
<void*, eHWSC_Num
>& shaders
= pDevicePsoDX11
->m_pDeviceShaders
;
665 BindShader(eHWSC_Compute
, (ID3D11Resource
*)shaders
[eHWSC_Compute
]);
668 void CDeviceComputeCommandInterfaceImpl::SetResourcesImpl(uint32 bindSlot
, const CDeviceResourceSet
* pResources
)
670 auto pResourcesDX11
= reinterpret_cast<const CDeviceResourceSet_DX11
*>(pResources
);
673 for (int slot
= 0; slot
< pResourcesDX11
->compiledSRVs
[eHWSC_Compute
].size(); ++slot
)
675 ID3D11ShaderResourceView
* pSrv
= pResourcesDX11
->compiledSRVs
[eHWSC_Compute
][slot
];
677 if (pSrv
!= CDeviceResourceSet_DX11::InvalidPointer
)
679 if (m_sharedState
.shaderResourceView
[eHWSC_Compute
][slot
].Set(pSrv
))
681 BindSRV(eHWSC_Compute
, pSrv
, slot
);
687 for (int slot
= 0; slot
< pResourcesDX11
->compiledSamplers
[eHWSC_Compute
].size(); ++slot
)
689 ID3D11SamplerState
* pSamplerState
= pResourcesDX11
->compiledSamplers
[eHWSC_Compute
][slot
];
691 if (pSamplerState
!= CDeviceResourceSet_DX11::InvalidPointer
)
693 if (m_sharedState
.samplerState
[eHWSC_Compute
][slot
].Set(pSamplerState
))
695 BindSampler(eHWSC_Compute
, pSamplerState
, slot
);
700 // Bind constant buffers
701 for (int i
= 0; i
< pResourcesDX11
->numCompiledCBs
[eHWSC_Compute
]; ++i
)
703 const CDeviceResourceSet_DX11::SCompiledConstantBuffer
& cb
= pResourcesDX11
->compiledCBs
[eHWSC_Compute
][i
];
704 if (m_sharedState
.constantBuffer
[eHWSC_Compute
][cb
.slot
].Set(cb
.code
))
706 BindConstantBuffer(eHWSC_Compute
, cb
.pBuffer
, cb
.slot
, cb
.offset
, cb
.size
);
711 for (int i
= 0; i
< pResourcesDX11
->numCompiledUAVs
; ++i
)
713 const CDeviceResourceSet_DX11::SCompiledUAV
& uav
= pResourcesDX11
->compiledUAVs
[i
];
714 BindUAV(uav
.shaderStage
, uav
.pUav
, uav
.slot
);
716 m_computeState
.custom
.boundUAVs
[uav
.slot
] = true;
720 void CDeviceComputeCommandInterfaceImpl::SetInlineConstantBufferImpl(uint32 bindSlot
, const CConstantBuffer
* pBuffer
, EConstantBufferShaderSlot shaderSlot
)
722 if (m_sharedState
.constantBuffer
[eHWSC_Compute
][shaderSlot
].Set(pBuffer
->GetCode()))
724 BindConstantBuffer(eHWSC_Compute
, pBuffer
->GetD3D(), shaderSlot
);
728 void CDeviceComputeCommandInterfaceImpl::SetInlineShaderResourceImpl(uint32 bindSlot
, const CDeviceBuffer
* pBuffer
, EShaderResourceShaderSlot shaderSlot
, ResourceViewHandle resourceViewID
)
730 D3DShaderResource
* pBufferViewDX11
= pBuffer
->LookupSRV(resourceViewID
);
732 if (m_sharedState
.shaderResourceView
[eHWSC_Compute
][shaderSlot
].Set(pBufferViewDX11
))
734 BindSRV(eHWSC_Compute
, pBufferViewDX11
, shaderSlot
);
738 void CDeviceComputeCommandInterfaceImpl::SetInlineConstantsImpl(uint32 bindSlot
, uint32 constantCount
, float* pConstants
)
743 void CDeviceComputeCommandInterfaceImpl::DispatchImpl(uint32 X
, uint32 Y
, uint32 Z
)
745 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
746 rd
->m_DevMan
.Dispatch(X
, Y
, Z
);
748 if (m_computeState
.custom
.boundUAVs
.any())
750 for (int i
= 0; i
< m_computeState
.custom
.boundUAVs
.size(); ++i
)
752 if (m_computeState
.custom
.boundUAVs
[i
])
754 BindUAV(eHWSC_Compute
, nullptr, i
);
758 rd
->m_DevMan
.CommitDeviceStates();
760 m_computeState
.custom
.boundUAVs
= 0;
761 memset(m_computeState
.pResourceSets
, 0x0, sizeof(m_computeState
.pResourceSets
));
765 void CDeviceComputeCommandInterfaceImpl::ClearUAVImpl(D3DUAV
* pView
, const FLOAT Values
[4], UINT NumRects
, const D3D11_RECT
* pRects
)
767 #if (CRY_RENDERER_DIRECT3D >= 120)
768 gcpRendD3D
->GetDeviceContext().ClearRectsUnorderedAccessViewFloat(pView
, Values
, NumRects
, pRects
);
770 CRY_ASSERT(NumRects
== 0); // not supported on dx11
771 gcpRendD3D
->GetDeviceContext().ClearUnorderedAccessViewFloat(pView
, Values
);
775 void CDeviceComputeCommandInterfaceImpl::ClearUAVImpl(D3DUAV
* pView
, const UINT Values
[4], UINT NumRects
, const D3D11_RECT
* pRects
)
777 #if (CRY_RENDERER_DIRECT3D >= 120)
778 gcpRendD3D
->GetDeviceContext().ClearRectsUnorderedAccessViewUint(pView
, Values
, NumRects
, pRects
);
780 CRY_ASSERT(NumRects
== 0); // not supported on dx11
781 gcpRendD3D
->GetDeviceContext().ClearUnorderedAccessViewUint(pView
, Values
);
785 void CDeviceComputeCommandInterfaceImpl::DiscardUAVContentsImpl(D3DResource
* pResource
, uint32 numRects
, const D3D11_RECT
* pRects
)
787 #if (CRY_RENDERER_DIRECT3D >= 111)
788 CRY_ASSERT(numRects
== 0); // not supported on dx11.1
789 gcpRendD3D
->GetDeviceContext().DiscardResource(pResource
);
793 void CDeviceComputeCommandInterfaceImpl::DiscardUAVContentsImpl(D3DBaseView
* pView
, uint32 numRects
, const D3D11_RECT
* pRects
)
795 #if (CRY_RENDERER_DIRECT3D >= 111)
797 gcpRendD3D
->GetDeviceContext().DiscardView1(pView
, numRects
, pRects
);
799 gcpRendD3D
->GetDeviceContext().DiscardView(pView
);
803 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
804 void CDeviceNvidiaCommandInterfaceImpl::SetModifiedWModeImpl(bool enabled
, uint32 numViewports
, const float* pA
, const float* pB
)
806 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
807 rd
->GetDeviceContext().SetModifiedWMode(enabled
, numViewports
, pA
, pB
);
810 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
811 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceBuffer
* pSrc
, CDeviceBuffer
* pDst
)
813 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
814 rd
->GetDeviceContext().CopyResource(pDst
->GetBaseBuffer(), pSrc
->GetBaseBuffer());
817 void CDeviceCopyCommandInterfaceImpl::CopyImpl(D3DBuffer
* pSrc
, D3DBuffer
* pDst
)
819 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
820 rd
->GetDeviceContext().CopyResource(pDst
, pSrc
);
823 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceTexture
* pSrc
, CDeviceTexture
* pDst
)
825 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
826 rd
->GetDeviceContext().CopyResource(pDst
->GetBaseTexture(), pSrc
->GetBaseTexture());
829 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceTexture
* pSrc
, D3DTexture
* pDst
)
831 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
832 rd
->GetDeviceContext().CopyResource(pDst
, pSrc
->GetBaseTexture());
835 void CDeviceCopyCommandInterfaceImpl::CopyImpl(D3DTexture
* pSrc
, D3DTexture
* pDst
)
837 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
838 rd
->GetDeviceContext().CopyResource(pDst
, pSrc
);
841 void CDeviceCopyCommandInterfaceImpl::CopyImpl(D3DTexture
* pSrc
, CDeviceTexture
* pDst
)
843 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
844 rd
->GetDeviceContext().CopyResource(pDst
->GetBaseTexture(), pSrc
);
847 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceBuffer
* pSrc
, CDeviceBuffer
* pDst
, const SResourceRegionMapping
& region
)
849 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
850 D3D11_BOX box
= { region
.SourceOffset
.Left
, region
.SourceOffset
.Top
, region
.SourceOffset
.Front
, region
.SourceOffset
.Left
+ region
.Extent
.Width
, region
.SourceOffset
.Top
+ region
.Extent
.Height
, region
.SourceOffset
.Front
+ region
.Extent
.Depth
};
852 #if (CRY_RENDERER_DIRECT3D >= 111)
853 rd
->GetDeviceContext().CopySubresourcesRegion1(pDst
->GetBaseBuffer(), region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
->GetBaseBuffer(), region
.SourceOffset
.Subresource
, &box
, region
.Flags
, region
.Extent
.Subresources
);
855 rd
->GetDeviceContext().CopySubresourcesRegion(pDst
->GetBaseBuffer(), region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
->GetBaseBuffer(), region
.SourceOffset
.Subresource
, &box
, region
.Extent
.Subresources
);
859 void CDeviceCopyCommandInterfaceImpl::CopyImpl(D3DBuffer
* pSrc
, D3DBuffer
* pDst
, const SResourceRegionMapping
& region
)
861 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
862 D3D11_BOX box
= { region
.SourceOffset
.Left
, region
.SourceOffset
.Top
, region
.SourceOffset
.Front
, region
.SourceOffset
.Left
+ region
.Extent
.Width
, region
.SourceOffset
.Top
+ region
.Extent
.Height
, region
.SourceOffset
.Front
+ region
.Extent
.Depth
};
864 #if (CRY_RENDERER_DIRECT3D >= 111)
865 rd
->GetDeviceContext().CopySubresourcesRegion1(pDst
, region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
, region
.SourceOffset
.Subresource
, &box
, region
.Flags
, region
.Extent
.Subresources
);
867 rd
->GetDeviceContext().CopySubresourcesRegion(pDst
, region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
, region
.SourceOffset
.Subresource
, &box
, region
.Extent
.Subresources
);
871 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceTexture
* pSrc
, CDeviceTexture
* pDst
, const SResourceRegionMapping
& region
)
873 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
874 D3D11_BOX box
= { region
.SourceOffset
.Left
, region
.SourceOffset
.Top
, region
.SourceOffset
.Front
, region
.SourceOffset
.Left
+ region
.Extent
.Width
, region
.SourceOffset
.Top
+ region
.Extent
.Height
, region
.SourceOffset
.Front
+ region
.Extent
.Depth
};
876 // If CopySubresourceRegion is used with Multisampled or D3D11_BIND_DEPTH_STENCIL Resources, then the whole Subresource must be copied. DstX, DstY, and DstZ must all be 0, while pSrcBox must be NULL.
877 D3D11_BOX
* pBox
= &box
;
878 if (pSrc
->IsResolvable())
882 CRY_ASSERT(region
.DestinationOffset
.Left
== 0);
883 CRY_ASSERT(region
.DestinationOffset
.Top
== 0);
884 CRY_ASSERT(region
.DestinationOffset
.Front
== 0);
887 #if (CRY_RENDERER_DIRECT3D >= 111)
888 rd
->GetDeviceContext().CopySubresourcesRegion1(pDst
->GetBaseTexture(), region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
->GetBaseTexture(), region
.SourceOffset
.Subresource
, pBox
, region
.Flags
, region
.Extent
.Subresources
);
890 rd
->GetDeviceContext().CopySubresourcesRegion(pDst
->GetBaseTexture(), region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
->GetBaseTexture(), region
.SourceOffset
.Subresource
, pBox
, region
.Extent
.Subresources
);
894 void CDeviceCopyCommandInterfaceImpl::CopyImpl(D3DTexture
* pSrc
, CDeviceTexture
* pDst
, const SResourceRegionMapping
& region
)
896 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
897 D3D11_BOX box
= { region
.SourceOffset
.Left
, region
.SourceOffset
.Top
, region
.SourceOffset
.Front
, region
.SourceOffset
.Left
+ region
.Extent
.Width
, region
.SourceOffset
.Top
+ region
.Extent
.Height
, region
.SourceOffset
.Front
+ region
.Extent
.Depth
};
899 #if (CRY_RENDERER_DIRECT3D >= 111)
900 rd
->GetDeviceContext().CopySubresourcesRegion1(pDst
->GetBaseTexture(), region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
, region
.SourceOffset
.Subresource
, &box
, region
.Flags
, region
.Extent
.Subresources
);
902 rd
->GetDeviceContext().CopySubresourcesRegion(pDst
->GetBaseTexture(), region
.DestinationOffset
.Subresource
, region
.DestinationOffset
.Left
, region
.DestinationOffset
.Top
, region
.DestinationOffset
.Front
, pSrc
, region
.SourceOffset
.Subresource
, &box
, region
.Extent
.Subresources
);
906 void CDeviceCopyCommandInterfaceImpl::CopyImpl(const void* pSrc
, CConstantBuffer
* pDst
, const SResourceMemoryAlignment
& memoryLayout
)
908 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
909 rd
->GetDeviceContext().UpdateSubresource(pDst
->GetD3D(), 0, nullptr, pSrc
, 0, 0);
912 void CDeviceCopyCommandInterfaceImpl::CopyImpl(const void* pSrc
, CDeviceBuffer
* pDst
, const SResourceMemoryAlignment
& memoryLayout
)
914 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
915 rd
->GetDeviceContext().UpdateSubresource(pDst
->GetBaseBuffer(), 0, nullptr, pSrc
, memoryLayout
.rowStride
, memoryLayout
.planeStride
);
918 void CDeviceCopyCommandInterfaceImpl::CopyImpl(const void* pSrc
, CDeviceTexture
* pDst
, const SResourceMemoryAlignment
& memoryLayout
)
920 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
921 rd
->GetDeviceContext().UpdateSubresource(pDst
->GetBaseTexture(), 0, nullptr, pSrc
, memoryLayout
.rowStride
, memoryLayout
.planeStride
);
924 void CDeviceCopyCommandInterfaceImpl::CopyImpl(const void* pSrc
, CConstantBuffer
* pDst
, const SResourceMemoryMapping
& region
)
926 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
927 CRY_ASSERT((region
.Extent
.Subresources
== 1) && ((region
.ResourceOffset
.Left
== 0) || (CRY_RENDERER_DIRECT3D
>= 111))); // TODO: batch
928 D3D11_BOX box
= { region
.ResourceOffset
.Left
, region
.ResourceOffset
.Top
, region
.ResourceOffset
.Front
, region
.ResourceOffset
.Left
+ region
.Extent
.Width
, region
.ResourceOffset
.Top
+ region
.Extent
.Height
, region
.ResourceOffset
.Front
+ region
.Extent
.Depth
};
929 #if (CRY_RENDERER_DIRECT3D >= 111)
930 rd
->GetDeviceContext().UpdateSubresource1(pDst
->GetD3D(), region
.ResourceOffset
.Subresource
, CRY_RENDERER_DIRECT3D
>= 111 ? &box
: nullptr, pSrc
, region
.MemoryLayout
.rowStride
, region
.MemoryLayout
.planeStride
, region
.Flags
);
932 rd
->GetDeviceContext().UpdateSubresource(pDst
->GetD3D(), region
.ResourceOffset
.Subresource
, CRY_RENDERER_DIRECT3D
>= 111 ? &box
: nullptr, pSrc
, region
.MemoryLayout
.rowStride
, region
.MemoryLayout
.planeStride
);
936 void CDeviceCopyCommandInterfaceImpl::CopyImpl(const void* pSrc
, CDeviceBuffer
* pDst
, const SResourceMemoryMapping
& region
)
938 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
939 CRY_ASSERT((region
.Extent
.Subresources
== 1) && (CRY_RENDERER_DIRECT3D
< 111)); // TODO: batch
940 D3D11_BOX box
= { region
.ResourceOffset
.Left
, region
.ResourceOffset
.Top
, region
.ResourceOffset
.Front
, region
.ResourceOffset
.Left
+ region
.Extent
.Width
, region
.ResourceOffset
.Top
+ region
.Extent
.Height
, region
.ResourceOffset
.Front
+ region
.Extent
.Depth
};
941 #if (CRY_RENDERER_DIRECT3D >= 111)
942 rd
->GetDeviceContext().UpdateSubresource1(pDst
->GetBaseBuffer(), region
.ResourceOffset
.Subresource
, &box
, pSrc
, region
.MemoryLayout
.rowStride
, region
.MemoryLayout
.planeStride
, region
.Flags
);
944 rd
->GetDeviceContext().UpdateSubresource(pDst
->GetBaseBuffer(), region
.ResourceOffset
.Subresource
, &box
, pSrc
, region
.MemoryLayout
.rowStride
, region
.MemoryLayout
.planeStride
);
948 void CDeviceCopyCommandInterfaceImpl::CopyImpl(const void* pSrc
, CDeviceTexture
* pDst
, const SResourceMemoryMapping
& region
)
950 CD3D9Renderer
* const __restrict rd
= gcpRendD3D
;
951 CRY_ASSERT(region
.Extent
.Subresources
== 1); // TODO: batch
952 D3D11_BOX box
= { region
.ResourceOffset
.Left
, region
.ResourceOffset
.Top
, region
.ResourceOffset
.Front
, region
.ResourceOffset
.Left
+ region
.Extent
.Width
, region
.ResourceOffset
.Top
+ region
.Extent
.Height
, region
.ResourceOffset
.Front
+ region
.Extent
.Depth
};
953 #if (CRY_RENDERER_DIRECT3D >= 111)
954 rd
->GetDeviceContext().UpdateSubresource1(pDst
->GetBaseTexture(), region
.ResourceOffset
.Subresource
, &box
, pSrc
, region
.MemoryLayout
.rowStride
, region
.MemoryLayout
.planeStride
, region
.Flags
);
956 rd
->GetDeviceContext().UpdateSubresource(pDst
->GetBaseTexture(), region
.ResourceOffset
.Subresource
, &box
, pSrc
, region
.MemoryLayout
.rowStride
, region
.MemoryLayout
.planeStride
);
960 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceBuffer
* pSrc
, void* pDst
, const SResourceMemoryAlignment
& memoryLayout
)
965 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceTexture
* pSrc
, void* pDst
, const SResourceMemoryAlignment
& memoryLayout
)
970 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceBuffer
* pSrc
, void* pDst
, const SResourceMemoryMapping
& region
)
975 void CDeviceCopyCommandInterfaceImpl::CopyImpl(CDeviceTexture
* pSrc
, void* pDst
, const SResourceMemoryMapping
& region
)