// Copyright (c) 2012-2017 VideoStitch SAS // Copyright (c) 2018 stitchEm #include "deviceHostBuffer.hpp" #include "deviceStream.hpp" #include "../common/allocStats.hpp" #include namespace VideoStitch { namespace GPU { // There is no pimpl in the OpenCL implementation, so there is no ::get() // template // const DeviceHostBuffer& HostBuffer::get(); template PotentialValue> HostBuffer::allocate(size_t numElements, const char* name, unsigned int /*flags*/) { T* buf = new T[numElements]; // TODO std::align to 4096 if (buf) { hostStats.addPtr(name, (void*)buf, numElements * sizeof(T)); return PotentialValue>(HostBuffer(nullptr, buf, numElements)); } return PotentialValue>( Status(Origin::GPU, ErrType::OutOfResources, "Failed to allocate " + std::to_string(numElements * sizeof(T)) + " Bytes of host memory. Reduce the project output size and close other applications to free up RAM.")); } template Status HostBuffer::release() { if (hostData) { hostStats.deletePtr((void*)hostData); delete[]((T*)hostData); return Status::OK(); } return Status::OK(); } template std::size_t HostBuffer::getPoolSize() { return hostStats.bytesUsed(); } template std::vector HostBuffer::getPoolSizeByDevices() { return hostStats.bytesUsedByDevices(); } template class HostBuffer; template class HostBuffer; template class HostBuffer; template class HostBuffer; } // namespace GPU } // namespace VideoStitch