From 61bfee05db60a67fb8be6e72b27ba6724f0dd277 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 24 Nov 2018 14:11:02 -0800 Subject: Moved/renamed `IBuffer::UpdateData()` to `IDeviceContext::UpdateBuffer()` Moved/renamed `IBuffer::CopyData()` to `IDeviceContext::CopyBuffer()` --- .../GraphicsEngineVulkan/include/BufferVkImpl.h | 2 -- .../include/DeviceContextVkImpl.h | 4 ++++ Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp | 16 --------------- .../src/DeviceContextVkImpl.cpp | 24 +++++++++++++++------- 4 files changed, 21 insertions(+), 25 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h index 9e888bec..ef93d90c 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h @@ -65,8 +65,6 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface )override; - virtual void UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData )override; - virtual void CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )override; virtual void Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData )override; virtual void Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags )override; diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 23d10485..c2176442 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -95,6 +95,10 @@ public: virtual void Flush()override final; + virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override final; + + virtual void CopyBuffer(IBuffer *pSrcBuffer, IBuffer *pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size)override final; + virtual void FinishCommandList(class ICommandList** ppCommandList)override final; virtual void ExecuteCommandList(class ICommandList* pCommandList)override final; diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index c31ac7c3..cb0fc958 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -303,22 +303,6 @@ BufferVkImpl :: ~BufferVkImpl() IMPLEMENT_QUERY_INTERFACE( BufferVkImpl, IID_BufferVk, TBufferBase ) -void BufferVkImpl::UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) -{ - TBufferBase::UpdateData( pContext, Offset, Size, pData ); - - // We must use cmd context from the device context provided, otherwise there will - // be resource barrier issues in the cmd list in the device context - auto *pDeviceContextVk = ValidatedCast(pContext); - pDeviceContextVk->UpdateBufferRegion(this, pData, Offset, Size); -} - -void BufferVkImpl :: CopyData(IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) -{ - TBufferBase::CopyData( pContext, pSrcBuffer, SrcOffset, DstOffset, Size ); - auto *pDeviceContextVk = ValidatedCast(pContext); - pDeviceContextVk->CopyBufferRegion(ValidatedCast(pSrcBuffer), this, SrcOffset, DstOffset, Size); -} void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData) { diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index e8316daf..3b2d961a 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1212,8 +1212,14 @@ namespace Diligent ++m_State.NumCommands; } - void DeviceContextVkImpl::UpdateBufferRegion(BufferVkImpl *pBuffVk, const void *pData, Uint64 DstOffset, Uint64 NumBytes) + void DeviceContextVkImpl::UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData) { + TDeviceContextBase::UpdateBuffer(pBuffer, Offset, Size, pData); + + // We must use cmd context from the device context provided, otherwise there will + // be resource barrier issues in the cmd list in the device context + auto* pBuffVk = ValidatedCast(pBuffer); + #ifdef DEVELOPMENT if (pBuffVk->GetDesc().Usage == USAGE_DYNAMIC) { @@ -1222,18 +1228,22 @@ namespace Diligent } #endif - VERIFY_EXPR( static_cast(NumBytes) == NumBytes ); constexpr size_t Alignment = 4; // Source buffer offset must be multiple of 4 (18.4) - auto TmpSpace = m_UploadHeap.Allocate(static_cast(NumBytes), Alignment); - memcpy(TmpSpace.CPUAddress, pData, static_cast(NumBytes)); - UpdateBufferRegion(pBuffVk, DstOffset, NumBytes, TmpSpace.vkBuffer, TmpSpace.AlignedOffset); + auto TmpSpace = m_UploadHeap.Allocate(Size, Alignment); + memcpy(TmpSpace.CPUAddress, pData, Size); + UpdateBufferRegion(pBuffVk, Offset, Size, TmpSpace.vkBuffer, TmpSpace.AlignedOffset); // The allocation will stay in the upload heap until the end of the frame at which point all upload // pages will be discarded } - void DeviceContextVkImpl::CopyBufferRegion(BufferVkImpl *pSrcBuffVk, BufferVkImpl *pDstBuffVk, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes) + void DeviceContextVkImpl::CopyBuffer(IBuffer* pSrcBuffer, IBuffer* pDstBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) { + TDeviceContextBase::CopyBuffer(pSrcBuffer, pDstBuffer, SrcOffset, DstOffset, Size); + + auto *pSrcBuffVk = ValidatedCast(pSrcBuffer); + auto *pDstBuffVk = ValidatedCast(pDstBuffer); + #ifdef DEVELOPMENT if (pDstBuffVk->GetDesc().Usage == USAGE_DYNAMIC) { @@ -1263,7 +1273,7 @@ namespace Diligent VkBufferCopy CopyRegion; CopyRegion.srcOffset = SrcOffset + pSrcBuffVk->GetDynamicOffset(m_ContextId, this); CopyRegion.dstOffset = DstOffset; - CopyRegion.size = NumBytes; + CopyRegion.size = Size; VERIFY(pDstBuffVk->m_VulkanBuffer != VK_NULL_HANDLE, "Copy destination buffer must not be suballocated"); VERIFY_EXPR(pDstBuffVk->GetDynamicOffset(m_ContextId, this) == 0); m_CommandBuffer.CopyBuffer(pSrcBuffVk->GetVkBuffer(), pDstBuffVk->GetVkBuffer(), 1, &CopyRegion); -- cgit v1.2.3