diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 22:11:02 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 22:11:02 +0000 |
| commit | 61bfee05db60a67fb8be6e72b27ba6724f0dd277 (patch) | |
| tree | b4595056fc881ccbca6fd50c7163d4df1cf54f19 /Graphics/GraphicsEngineVulkan | |
| parent | Updated debug message about required shader resource binding object (diff) | |
| download | DiligentCore-61bfee05db60a67fb8be6e72b27ba6724f0dd277.tar.gz DiligentCore-61bfee05db60a67fb8be6e72b27ba6724f0dd277.zip | |
Moved/renamed `IBuffer::UpdateData()` to `IDeviceContext::UpdateBuffer()`
Moved/renamed `IBuffer::CopyData()` to `IDeviceContext::CopyBuffer()`
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
4 files changed, 21 insertions, 25 deletions
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<DeviceContextVkImpl>(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<DeviceContextVkImpl>(pContext); - pDeviceContextVk->CopyBufferRegion(ValidatedCast<BufferVkImpl>(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<BufferVkImpl>(pBuffer); + #ifdef DEVELOPMENT if (pBuffVk->GetDesc().Usage == USAGE_DYNAMIC) { @@ -1222,18 +1228,22 @@ namespace Diligent } #endif - VERIFY_EXPR( static_cast<size_t>(NumBytes) == NumBytes ); constexpr size_t Alignment = 4; // Source buffer offset must be multiple of 4 (18.4) - auto TmpSpace = m_UploadHeap.Allocate(static_cast<size_t>(NumBytes), Alignment); - memcpy(TmpSpace.CPUAddress, pData, static_cast<size_t>(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<BufferVkImpl>(pSrcBuffer); + auto *pDstBuffVk = ValidatedCast<BufferVkImpl>(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); |
