9 if (mData.size() != src.size())
10 this->resize(src.size());
21 class Array<
T, DeviceType::GPU>
38 void resize(
const uint n);
53 inline const VkDeviceArray<T>* handle()
const {
return &mData; }
54 inline VkDeviceArray<T>* handle() {
return &mData; }
56 VkBuffer buffer()
const {
return mData.bufferHandle(); }
58 uint32_t bufferSize() {
return mData.bufferSize(); }
60 DeviceType deviceType() {
return DeviceType::GPU; }
62 inline T& operator [] (
unsigned int id) {
66 inline T& operator [] (
unsigned int id)
const {
70 inline uint size()
const {
return mData.size(); }
71 inline bool isCPU()
const {
return false; }
72 inline bool isGPU()
const {
return true; }
73 inline bool isEmpty()
const {
return mData.size() == 0; }
75 void assign(
const Array<T, DeviceType::GPU>& src);
76 void assign(
const Array<T, DeviceType::CPU>& src);
77 void assign(
const std::vector<T>& src);
79 void assign(
const Array<T, DeviceType::GPU>& src,
const uint count,
const uint dstOffset = 0,
const uint srcOffset = 0);
80 void assign(
const Array<T, DeviceType::CPU>& src,
const uint count,
const uint dstOffset = 0,
const uint srcOffset = 0);
81 void assign(
const std::vector<T>& src,
const uint count,
const uint dstOffset = 0,
const uint srcOffset = 0);
83 friend std::ostream& operator<<(std::ostream& out,
const Array<T, DeviceType::GPU>& dArray)
85 Array<T, DeviceType::CPU> hArray;
86 hArray.assign(dArray);
94 VkDeviceArray<T> mData;
103 if (mData.size() == n)
return;
135 if (mData.size() != src.size())
136 this->resize(src.size());
145 if (mData.size() != src.size())
146 this->resize(src.size());
156 if (mData.size() != src.size())
157 this->resize((
uint)src.size());
178 vkTransfer(mData, (uint64_t)dstOffset, *src.handle(), (uint64_t)srcOffset, (uint64_t)count);
This class is designed to be elegant, so it can be directly passed to GPU as parameters.
This is an implementation of AdditiveCCD based on peridyno.
Array< T, DeviceType::GPU > DArray
bool vkTransfer(VkHostArray< T > &dst, const VkDeviceArray< T > &src)