createDeviceBuffer method
- StorageMode storageMode,
- int sizeInBytes
Allocates a new region of GPU-resident memory.
The storageMode
must be either StorageMode.hostVisible or
StorageMode.devicePrivate, otherwise an exception will be thrown.
Returns null
if the DeviceBuffer creation failed.
Implementation
DeviceBuffer? createDeviceBuffer(StorageMode storageMode, int sizeInBytes) {
if (storageMode == StorageMode.deviceTransient) {
throw Exception(
'DeviceBuffers cannot be set to StorageMode.deviceTransient');
}
DeviceBuffer result =
DeviceBuffer._initialize(this, storageMode, sizeInBytes);
return result.isValid ? result : null;
}