summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-06-17 20:02:42 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-06-17 20:02:42 +0000
commita04c8aa513c465bf2b01ae5ee93034027bdc74b8 (patch)
tree484451cc1aec8a6ac970515046a98b6d6a724c41 /Graphics/GraphicsEngineVulkan
parentEnabled DispatchCompute() in Vulkan backend (diff)
downloadDiligentCore-a04c8aa513c465bf2b01ae5ee93034027bdc74b8.tar.gz
DiligentCore-a04c8aa513c465bf2b01ae5ee93034027bdc74b8.zip
Added update of the dynamic texel buffer in Vk
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp7
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp14
3 files changed, 14 insertions, 9 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
index 020c3270..170cbcc7 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
@@ -116,7 +116,7 @@ public:
///// Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute)
//static constexpr int NumShaderTypes = 6;
- void UpdateBufferRegion(class BufferVkImpl* pBuffVk, VulkanUtilities::VulkanUploadAllocation& Allocation, Uint64 DstOffset, Uint64 NumBytes);
+ void UpdateBufferRegion(class BufferVkImpl* pBuffVk, Uint64 DstOffset, Uint64 NumBytes, VkBuffer vkSrcBuffer, Uint64 SrcOffset);
void UpdateBufferRegion(class BufferVkImpl* pBuffVk, const void *pData, Uint64 DstOffset, Uint64 NumBytes);
void CopyBufferRegion(class BufferVkImpl *pSrcBuffVk, class BufferVkImpl *pDstBuffVk, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes);
diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
index c06570b9..a5bf6c38 100644
--- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
@@ -440,7 +440,12 @@ void BufferVkImpl::Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 Map
else if (m_Desc.Usage == USAGE_DYNAMIC)
{
VERIFY(MapFlags & MAP_FLAG_DISCARD, "Vk buffer must be mapped for writing with MAP_FLAG_DISCARD flag");
- //pDeviceContextVk->CopyAndFreeDynamicUploadData(this);
+ if(m_VulkanBuffer != VK_NULL_HANDLE)
+ {
+ auto &DynAlloc = m_DynamicAllocations[CtxId];
+ auto vkSrcBuff = DynAlloc.pParentDynamicHeap->GetVkBuffer();
+ pDeviceContextVk->UpdateBufferRegion(this, 0, m_Desc.uiSizeInBytes, vkSrcBuff, DynAlloc.Offset);
+ }
}
}
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index 1a25e379..4a739279 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -983,21 +983,20 @@ namespace Diligent
}
}
- void DeviceContextVkImpl::UpdateBufferRegion(BufferVkImpl *pBuffVk, VulkanUtilities::VulkanUploadAllocation& Allocation, Uint64 DstOffset, Uint64 NumBytes)
+ void DeviceContextVkImpl::UpdateBufferRegion(BufferVkImpl* pBuffVk, Uint64 DstOffset, Uint64 NumBytes, VkBuffer vkSrcBuffer, Uint64 SrcOffset)
{
VERIFY(DstOffset + NumBytes <= pBuffVk->GetDesc().uiSizeInBytes, "Update region is out of buffer");
- VERIFY_EXPR(NumBytes <= Allocation.MemAllocation.Size);
EnsureVkCmdBuffer();
- if(!pBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_WRITE_BIT))
+ if (!pBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_WRITE_BIT))
{
BufferMemoryBarrier(*pBuffVk, VK_ACCESS_TRANSFER_WRITE_BIT);
}
VkBufferCopy CopyRegion;
- CopyRegion.srcOffset = Allocation.MemAllocation.UnalignedOffset;
+ CopyRegion.srcOffset = SrcOffset;
CopyRegion.dstOffset = DstOffset;
CopyRegion.size = NumBytes;
VERIFY(pBuffVk->m_VulkanBuffer != VK_NULL_HANDLE, "Copy destination buffer must not be suballocated");
- m_CommandBuffer.CopyBuffer(Allocation.vkBuffer, pBuffVk->GetVkBuffer(), 1, &CopyRegion);
+ m_CommandBuffer.CopyBuffer(vkSrcBuffer, pBuffVk->GetVkBuffer(), 1, &CopyRegion);
++m_State.NumCommands;
}
@@ -1008,7 +1007,7 @@ namespace Diligent
auto TmpSpace = m_UploadHeap.Allocate(NumBytes);
auto CPUAddress = TmpSpace.MemAllocation.Page->GetCPUMemory();
memcpy(reinterpret_cast<Uint8*>(CPUAddress) + TmpSpace.MemAllocation.UnalignedOffset, pData, static_cast<size_t>(NumBytes));
- UpdateBufferRegion(pBuffVk, TmpSpace, DstOffset, NumBytes);
+ UpdateBufferRegion(pBuffVk, DstOffset, NumBytes, TmpSpace.vkBuffer, TmpSpace.MemAllocation.UnalignedOffset);
// The allocation will stay in the queue until the command buffer from this context is submitted
// to the queue. We cannot use the device's release queue as other contexts may interfer with
// the release order
@@ -1284,7 +1283,8 @@ namespace Diligent
auto it = m_UploadAllocations.find(pBuffer);
if(it != m_UploadAllocations.end())
{
- UpdateBufferRegion(pBuffer, it->second, 0, pBuffer->GetDesc().uiSizeInBytes);
+ VERIFY_EXPR(pBuffer->GetDesc().uiSizeInBytes <= it->second.MemAllocation.Size);
+ UpdateBufferRegion(pBuffer, 0, pBuffer->GetDesc().uiSizeInBytes, it->second.vkBuffer, it->second.MemAllocation.UnalignedOffset);
// The allocation will stay in the queue until the command buffer from this context is submitted
// to the queue. We cannot use the device's release queue as other contexts may interfer with
// the release order