diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-12-03 04:08:06 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-12-03 04:08:06 +0000 |
| commit | 57d21b1b34187df0ff1a3d31b85285fa2e21c9e5 (patch) | |
| tree | e48bb2aa8af6f9c01044f7d4a5cf6b479cb067cb /Graphics/GraphicsEngineD3D12 | |
| parent | Few minor updates to VariableSizeAllocationsManager (diff) | |
| download | DiligentCore-57d21b1b34187df0ff1a3d31b85285fa2e21c9e5.tar.gz DiligentCore-57d21b1b34187df0ff1a3d31b85285fa2e21c9e5.zip | |
Added IDeviceContext::GetFrameNumber() method (API )
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
3 files changed, 4 insertions, 6 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp index 91c1610a..4eb3585b 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp @@ -312,8 +312,6 @@ public: size_t GetNumCommandsInCtx() const { return m_State.NumCommands; } - Int64 GetCurrentFrameNumber() const { return m_ContextFrameNumber; } - private: void CommitD3D12IndexBuffer(GraphicsContext& GraphCtx, VALUE_TYPE IndexType); void CommitD3D12VertexBuffers(class GraphicsContext& GraphCtx); diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp index d7cd54b6..0d0ac327 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp @@ -404,9 +404,9 @@ ID3D12Resource* BufferD3D12Impl::GetD3D12Buffer(Uint64& DataStartByteOffset, IDe void BufferD3D12Impl::DvpVerifyDynamicAllocation(DeviceContextD3D12Impl* pCtx) const { auto ContextId = pCtx->GetContextId(); - auto CurrentFrame = pCtx->GetCurrentFrameNumber(); + auto CurrentFrame = pCtx->GetFrameNumber(); DEV_CHECK_ERR(m_DynamicData[ContextId].GPUAddress != 0, "Dynamic buffer '", m_Desc.Name, "' has not been mapped before its first use. Context Id: ", ContextId, ". Note: memory for dynamic buffers is allocated when a buffer is mapped."); - DEV_CHECK_ERR(m_DynamicData[ContextId].DvpCtxFrameNumber == static_cast<Uint64>(CurrentFrame), "Dynamic allocation of dynamic buffer '", m_Desc.Name, "' in frame ", CurrentFrame, " is out-of-date. Note: contents of all dynamic resources is discarded at the end of every frame. A buffer must be mapped before its first use in any frame."); + DEV_CHECK_ERR(m_DynamicData[ContextId].DvpCtxFrameNumber == CurrentFrame, "Dynamic allocation of dynamic buffer '", m_Desc.Name, "' in frame ", CurrentFrame, " is out-of-date. Note: contents of all dynamic resources is discarded at the end of every frame. A buffer must be mapped before its first use in any frame."); VERIFY(GetState() == RESOURCE_STATE_GENERIC_READ, "Dynamic buffers are expected to always be in RESOURCE_STATE_GENERIC_READ state"); } #endif diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 938c9468..45e6be49 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -1313,7 +1313,7 @@ void DeviceContextD3D12Impl::EndRenderPass() D3D12DynamicAllocation DeviceContextD3D12Impl::AllocateDynamicSpace(size_t NumBytes, size_t Alignment) { - return m_DynamicHeap.Allocate(NumBytes, Alignment, m_ContextFrameNumber); + return m_DynamicHeap.Allocate(NumBytes, Alignment, GetFrameNumber()); } void DeviceContextD3D12Impl::UpdateBufferRegion(BufferD3D12Impl* pBuffD3D12, @@ -1346,7 +1346,7 @@ void DeviceContextD3D12Impl::UpdateBuffer(IBuffer* pBuffer auto* pBuffD3D12 = ValidatedCast<BufferD3D12Impl>(pBuffer); VERIFY(pBuffD3D12->GetDesc().Usage != USAGE_DYNAMIC, "Dynamic buffers must be updated via Map()"); constexpr size_t DefaultAlginment = 16; - auto TmpSpace = m_DynamicHeap.Allocate(Size, DefaultAlginment, m_ContextFrameNumber); + auto TmpSpace = m_DynamicHeap.Allocate(Size, DefaultAlginment, GetFrameNumber()); memcpy(TmpSpace.CPUAddress, pData, Size); UpdateBufferRegion(pBuffD3D12, TmpSpace, Offset, Size, StateTransitionMode); } |
