11 #ifndef __CE_VDBCreate__
12 #define __CE_VDBCreate__
39 ptrAssert(
const void*
ptr,
const char* msg,
const char* file,
int line)
54 bufferAssert(
const void*
buf,
const char* msg,
const char* file,
int line)
63 #define CEcheckPtr(ptr, msg) \
65 ptrAssert((ptr).get(), (msg), __FILE__, __LINE__); \
68 #define CEcheckBuffer(buf, msg) \
70 bufferAssert((buf), (msg), __FILE__, __LINE__); \
97 , myGpuData(cl::Buffer())
99 if (size > 0) this->
init(size, host);
107 : mySize(std::
exchange(other.mySize, 0))
108 , myCpuData(std::move(other.myCpuData))
109 , myGpuData(std::
exchange(other.myGpuData, cl::Buffer()))
121 myCpuData = std::move(other.myCpuData);
134 void init(uint64_t size,
bool host =
true);
138 uint8_t*
data()
const {
return myCpuData.get(); }
159 uint64_t
size()
const {
return mySize; }
163 bool empty()
const {
return mySize == 0; }
194 myCpuData = UTmakeUniqueForOverwrite<uint8_t[]>(
size);
195 CEcheckPtr(myCpuData,
"OclDeviceBuffer::init: failed to allocate host buffer");
201 CEcheckBuffer(myGpuData(),
"OclDeviceBuffer::init: failed to allocate device buffer");
211 CEcheckPtr(myCpuData,
"uninitialized cpu data");
212 if (myGpuData() ==
nullptr)
216 context->
writeBuffer(myGpuData, mySize, myCpuData.get());
225 if (myCpuData ==
nullptr)
226 myCpuData = UTmakeUniqueForOverwrite<uint8_t[]>(mySize);
227 CEcheckPtr(myCpuData,
"uninitialized cpu data");
229 context->
readBuffer(myGpuData, mySize, myCpuData.get());
236 if (myGpuData() !=
nullptr)
243 struct OclPointsData;
258 uint32_t bit_shift_right = 0);
268 uint32_t buffer_nelem = -1);
279 return myDataPtr !=
nullptr;
298 const bool activateleaves,
299 const uint32_t leafdilation,
302 const BuildT& bgvalue,
#define CEcheckBuffer(buf, msg)
GLenum GLuint GLenum GLsizei const GLchar * buf
const cl::Buffer & deviceData() const
Retuns a cl::Buffer ref to the device/GPU buffer managed by this allocator.
GridClass
Classes (superset of OpenVDB) that are currently supported by NanoVDB.
#define UTdebugFormatCd(...)
void releaseBuffer(cl::Buffer &&buf, bool use_pool=true)
Release the specified buffer, possibly to the CE_MemoryPool.
#define CEcheckPtr(ptr, msg)
OclDeviceBuffer(uint64_t size=0, bool host=true)
Constructor.
uint8_t * data() const
Retuns a raw pointer to the host/CPU buffer managed by this allocator.
OclDeviceBuffer & operator=(OclDeviceBuffer &&other) noexcept
Move copy assignment operation.
void init(uint64_t size, bool host=true)
Initialize buffer.
void writeBuffer(const cl::Buffer &buf, size_t size, const void *p, bool blocking=true, size_t offset=0)
Write the specified number of bytes to the buffer.
Defines GridHandle, which manages a host, and possibly a device, memory buffer containing one or more...
uint64_t size() const
Returns the size in bytes of the raw memory buffer managed by this allocator.
This class serves to manage a buffer containing one or more NanoVDB Grids.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
#define NANOVDB_DATA_ALIGNMENT
static CE_Context * getContext(bool gl_shared=true, bool shared_fallback=true)
~OclDeviceBuffer()
Destructor frees memory on both the host and device.
Implements a light-weight self-contained VDB data-structure in a single file! In other words...
void readBuffer(const cl::Buffer &buf, size_t size, void *p, bool blocking=true, size_t offset=0)
Read the specified number of bytes from the buffer.
static OclDeviceBuffer create(uint64_t size, bool host=true)
Static factory method that return an instance of this buffer.
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
HostBuffer - a buffer that contains a shared or private bump pool to either externally or internally ...
OclDeviceBuffer & operator=(const OclDeviceBuffer &)=delete
Disallow copy assignment operation.
static constexpr bool hasDeviceDual
cl::Buffer allocBuffer(int64 size, bool use_pool=true, bool read=true, bool write=true, uint32 ogl_bind=SYS_UINT32_MAX)
bool isEmpty() const
Returns true if this allocator is empty, i.e. has no allocated memory.
void clear()
De-allocate all memory managed by this allocator and set all pointers to NULL.
static nanovdb::GridHandle< BufferT > oclPointsToGrid(const PtrT d_ijk, uint32_t voxelcount, double voxelsize, const bool activateleaves, const uint32_t leafdilation, const UT_StringHolder &gridname, const nanovdb::GridClass gridclass, const BuildT &bgvalue, cl::Buffer &tilestart, exint &leafcount, exint &lowercount, exint &uppercount, DataCache *datacacheptr)
void deviceUpload(void *stream=nullptr, bool sync=true)
Upload this buffer from the host to the device, i.e. CPU -> GPU.
GLenum GLsizei GLsizei GLint * values
VULKAN_HPP_CONSTEXPR_14 VULKAN_HPP_INLINE T exchange(T &obj, U &&newValue)
void deviceDownload(void *stream=nullptr, bool sync=true)
Upload this buffer from the device to the host, i.e. GPU -> CPU.
OclDeviceBuffer(OclDeviceBuffer &&other) noexcept
Move copy-constructor.
bool empty() const
Returns true if this allocator is empty, i.e. has no allocated memory.
png_structrp int png_fixed_point red