-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVulkanStagingBuffers.cpp
51 lines (41 loc) · 1.43 KB
/
VulkanStagingBuffers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/******************************************************************************
This file is part of the Newcastle Vulkan Tutorial Series
Author:Rich Davison
Contact:[email protected]
License: MIT (see LICENSE file at the top of the source tree)
*//////////////////////////////////////////////////////////////////////////////
#include "VulkanStagingBuffers.h"
#include "VulkanBufferBuilder.h"
using namespace NCL;
using namespace Rendering;
using namespace Vulkan;
VulkanStagingBuffers::VulkanStagingBuffers(vk::Device inDevice, VmaAllocator inAllocator, uint32_t inFramesInFlight) {
device = inDevice;
allocator = inAllocator;
framesInFlight = inFramesInFlight;
}
VulkanStagingBuffers::~VulkanStagingBuffers() {
}
const VulkanBuffer* VulkanStagingBuffers::GetStagingBuffer(size_t allocationSize) {
activeBuffers.emplace_back(
BufferBuilder(device, allocator)
.WithBufferUsage(vk::BufferUsageFlagBits::eTransferSrc)
.WithHostVisibility()
.Build(allocationSize, "Staging Buffer"),
framesInFlight);
return &activeBuffers.back().buffer;
return nullptr;
}
void VulkanStagingBuffers::Update() {
for (std::vector<StagingBuffer>::iterator i = activeBuffers.begin();
i != activeBuffers.end(); )
{
(*i).framesCount--;
if ((*i).framesCount == 0) {
i = activeBuffers.erase(i);
}
else {
++i;
}
}
}