PeriDyno 1.0.0
Loading...
Searching...
No Matches
VkDeviceArray.inl
Go to the documentation of this file.
1namespace dyno {
2
3 template<typename T>
7
8 template<typename T>
10 {
11 this->resize(num);
12 }
14 template<typename T>
15 VkResizeType VkDeviceArray<T>::resize(uint32_t num, VkBufferUsageFlags usageFlags)
16 {
17 uint32_t newSize = num * sizeof(T);
18 uint32_t bufferSize = this->bufferSize();
19
20 if (newSize > bufferSize)
21 {
22 m_num = num;
23
24 buffer->destroy();
25
26 if (num > 0)
27 {
28 if (ctx->useMemoryPool) {
29 buffer->size = newSize;
30 buffer->usageFlags = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
31 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | usageFlags;
32 buffer->memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
33 ctx->createBuffer(VkContext::DevicePool, buffer);
34 }
35 else {
36 ctx->createBuffer(
37 usageFlags | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
38 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
39 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
40 buffer,
41 newSize);
42 }
43 }
44
46 }
47 else
48 {
49 m_num = num;
50 return VK_BUFFER_REUSED;
51 }
52 }
53
54 template<typename T>
59
60 template<typename T>
62 {
63 m_num = 0;
64 buffer->destroy();
65 }
66
67 template<typename T>
69 {
70 m_num = 0;
71 }
72}
VkResizeType resize(uint32_t num, VkBufferUsageFlags usageFlags=0)
uint32_t bufferSize() override
VariableType type() override
VkContext * ctx
Definition VkVariable.h:48
std::shared_ptr< vks::Buffer > buffer
Definition VkVariable.h:50
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
VariableType
Definition VkVariable.h:14
@ DeviceBuffer
Device buffer.
Definition VkVariable.h:15
VkResizeType
Definition VkVariable.h:22
@ VK_BUFFER_REUSED
Definition VkVariable.h:24
@ VK_BUFFER_REALLOCATED
Definition VkVariable.h:23