diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-06-01 15:50:12 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-06-01 15:50:12 +0000 |
| commit | aec03e953af606b7c5480a6e79f883bd53a0f561 (patch) | |
| tree | ea49be947137359c4bf71e8a2e8c89050b9c807b /Graphics/GraphicsEngineVulkan | |
| parent | Implemented indirect rendering in Vk (diff) | |
| download | DiligentCore-aec03e953af606b7c5480a6e79f883bd53a0f561.tar.gz DiligentCore-aec03e953af606b7c5480a6e79f883bd53a0f561.zip | |
Implemented buffer copy in Vk
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
4 files changed, 22 insertions, 17 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h index e914e195..c35863f0 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h @@ -62,9 +62,9 @@ public: virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )override; virtual void Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags )override; -#ifdef _DEBUG - void DbgVerifyDynamicAllocation(Uint32 ContextId); -#endif +//#ifdef _DEBUG +// void DbgVerifyDynamicAllocation(Uint32 ContextId); +//#endif VkBuffer GetVkBuffer()const override final diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 5e4dac38..99b08f73 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -114,8 +114,9 @@ public: void UpdateBufferRegion(class BufferVkImpl *pBuffVk, struct VulkanDynamicAllocation& Allocation, Uint64 DstOffset, Uint64 NumBytes); void UpdateBufferRegion(class BufferVkImpl *pBuffVk, const void *pData, Uint64 DstOffset, Uint64 NumBytes); -#if 0 + void CopyBufferRegion(class BufferVkImpl *pSrcBuffVk, class BufferVkImpl *pDstBuffVk, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes); +#if 0 void CopyTextureRegion(class TextureVkImpl *pSrcTexture, Uint32 SrcSubResIndex, const Vk_BOX *pVkSrcBox, class TextureVkImpl *pDstTexture, Uint32 DstSubResIndex, Uint32 DstX, Uint32 DstY, Uint32 DstZ); void CopyTextureRegion(IBuffer *pSrcBuffer, Uint32 SrcStride, Uint32 SrcDepthStride, class TextureVkImpl *pTextureVk, Uint32 DstSubResIndex, const Box &DstBox); diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index 96f26de4..8a1dee7e 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -328,11 +328,9 @@ void BufferVkImpl::UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 S void BufferVkImpl :: CopyData(IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) { -#if 0 TBufferBase::CopyData( pContext, pSrcBuffer, SrcOffset, DstOffset, Size ); auto *pDeviceContextVk = ValidatedCast<DeviceContextVkImpl>(pContext); pDeviceContextVk->CopyBufferRegion(ValidatedCast<BufferVkImpl>(pSrcBuffer), this, SrcOffset, DstOffset, Size); -#endif } 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 0ba8ea70..35b5104f 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -930,24 +930,30 @@ namespace Diligent UpdateBufferRegion(pBuffVk, TmpSpace, DstOffset, NumBytes); } -#if 0 void DeviceContextVkImpl::CopyBufferRegion(BufferVkImpl *pSrcBuffVk, BufferVkImpl *pDstBuffVk, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes) { VERIFY(pDstBuffVk->GetDesc().Usage != USAGE_DYNAMIC, "Dynamic buffers cannot be copy destinations"); - auto pCmdCtx = RequestCmdContext(); - pCmdCtx->TransitionResource(pSrcBuffVk, Vk_RESOURCE_STATE_COPY_SOURCE); - pCmdCtx->TransitionResource(pDstBuffVk, Vk_RESOURCE_STATE_COPY_DEST, true); - size_t DstDataStartByteOffset; - auto *pVkDstBuff = pDstBuffVk->GetVkBuffer(DstDataStartByteOffset, m_ContextId); - VERIFY(DstDataStartByteOffset == 0, "Dst buffer must not be suballocated"); - - size_t SrcDataStartByteOffset; - auto *pVkSrcBuff = pSrcBuffVk->GetVkBuffer(SrcDataStartByteOffset, m_ContextId); - pCmdCtx->GetCommandList()->CopyBufferRegion( pVkDstBuff, DstOffset + DstDataStartByteOffset, pVkSrcBuff, SrcOffset+SrcDataStartByteOffset, NumBytes); + EnsureVkCmdBuffer(); + if(!pSrcBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_READ_BIT)) + BufferMemoryBarrier(*pSrcBuffVk, VK_ACCESS_TRANSFER_READ_BIT); + if(!pDstBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_WRITE_BIT)) + BufferMemoryBarrier(*pDstBuffVk, VK_ACCESS_TRANSFER_WRITE_BIT); + VkBufferCopy CopyRegion; + CopyRegion.srcOffset = SrcOffset; + CopyRegion.dstOffset = DstOffset; + CopyRegion.size = NumBytes; + //size_t DstDataStartByteOffset; + //auto *pVkDstBuff = pDstBuffVk->GetVkBuffer(DstDataStartByteOffset, m_ContextId); + //VERIFY(DstDataStartByteOffset == 0, "Dst buffer must not be suballocated"); + + //size_t SrcDataStartByteOffset; + //auto *pVkSrcBuff = pSrcBuffVk->GetVkBuffer(SrcDataStartByteOffset, m_ContextId); + m_CommandBuffer.CopyBuffer(pSrcBuffVk->GetVkBuffer(), pDstBuffVk->GetVkBuffer(), 1, &CopyRegion); ++m_State.NumCommands; } +#if 0 void DeviceContextVkImpl::CopyTextureRegion(TextureVkImpl *pSrcTexture, Uint32 SrcSubResIndex, const Vk_BOX *pVkSrcBox, TextureVkImpl *pDstTexture, Uint32 DstSubResIndex, Uint32 DstX, Uint32 DstY, Uint32 DstZ) { |
