PeriDyno 1.0.0
Loading...
Searching...
No Matches
VkDeviceArray3D.inl
Go to the documentation of this file.
1namespace dyno {
2
3 template<typename T>
7
8 template<typename T>
9 VkDeviceArray3D<T>::VkDeviceArray3D(uint32_t nx, uint32_t ny, uint32_t nz)
10 {
11 this->resize(nx, ny, nz);
12 }
13
14 template<typename T>
15 void VkDeviceArray3D<T>::resize(uint32_t nx, uint32_t ny, uint32_t nz, VkBufferUsageFlags usageFlags)
16 {
17 buffer->destroy();
18
19 m_nx = nx;
20 m_ny = ny;
22 m_num = nx * ny * nz;
24 if (m_num > 0)
25 {
26 if (ctx->useMemoryPool) {
27 buffer->size = m_num * sizeof(T);
28 buffer->usageFlags = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
29 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | usageFlags;
30 buffer->memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
31 ctx->createBuffer(VkContext::DevicePool, buffer);
32 } else {
33 ctx->createBuffer(
34 usageFlags | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
35 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
36 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
37 buffer,
38 m_num * sizeof(T));
39 }
40 }
41 }
42
43 template<typename T>
44 uint32_t VkDeviceArray3D<T>::index(uint32_t i, uint32_t j, uint32_t k)
45 {
46 return i + j * m_nx + k * m_nx * m_ny;
47 }
48
49 template<typename T>
54
55 template<typename T>
57 {
58 m_nx = 0;
59 m_ny = 0;
60 m_nz = 0;
61 m_num = 0;
62 buffer->destroy();
63 }
64
65 template<typename T>
67 {
68 Array3DInfo info;
69 info.nx = m_nx;
70 info.ny = m_ny;
71 info.nz = m_nz;
72 info.nxy = m_nx * m_ny;
73
74 return info;
75 }
76}
uint32_t nx() const
VariableType type() override
void resize(uint32_t nx, uint32_t ny, uint32_t nz, VkBufferUsageFlags usageFlags=0)
uint32_t nz() const
uint32_t ny() const
uint32_t index(uint32_t i, uint32_t j, uint32_t k)
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