From 57d21b1b34187df0ff1a3d31b85285fa2e21c9e5 Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 2 Dec 2020 20:08:06 -0800 Subject: Added IDeviceContext::GetFrameNumber() method (API ) --- Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp | 2 -- Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp | 4 ++-- Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') 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(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(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); } -- cgit v1.2.3