11 #ifndef __CE_BufferDevice__
12 #define __CE_BufferDevice__
98 bool block =
true)
const;
137 template <
typename T>
143 if (mySize > 0 && doalloc)
147 template <
typename T>
151 initInternal(size,
true);
154 template <
typename T>
162 if (len >= 0 && len <= size)
167 size_t totalsize = size *
sizeof(
T);
169 context->writeBuffer(myBuffer, totalsize, src.
data(), blocking);
172 template <
typename T>
178 size_t size = mySize;
181 if (len >= 0 && len <= size)
187 size_t totalsize = size *
sizeof(
T);
191 template <
typename T>
199 size_t totalsize = nelem *
sizeof(
T);
201 context->writeBuffer(myBuffer, totalsize, data, blocking);
204 template <
typename T>
214 template <
typename T>
223 template <
typename T>
235 size_t totalsize = size *
sizeof(
T);
CE_BufferDevice(CE_BufferDevice< T > &&b) noexcept
GLenum GLuint GLenum GLsizei const GLchar * buf
void reset(cl::Buffer &&buf, exint size=-1)
void setSizeNoInit(exint newsize)
void initFromArray(const UT_Array< T > &src, exint len=-1, bool block=true)
Initialize from a UT_Array. If len >= 0, only len elements are copied.
void releaseBuffer(cl::Buffer &&buf, bool use_pool=true)
Release the specified buffer, possibly to the CE_MemoryPool.
GLboolean GLboolean GLboolean GLboolean a
void copyFrom(const CE_BufferDevice< T > &b, exint len=-1)
exint size() const
Returns the buffer length.
void initInternal(exint size, bool doalloc=true)
static CE_Context * getContext(bool gl_shared=true, bool shared_fallback=true)
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.
void initFromData(const T *data, exint nelem, bool block=true)
Initialize from raw data block of T elements of length nelem.
#define utZoneScopedFlag(F)
CE_BufferDevice(cl::Buffer &&buf, exint size=-1)
cl::Buffer allocBuffer(int64 size, bool use_pool=true, bool read=true, bool write=true, uint32 ogl_bind=SYS_UINT32_MAX)
GLboolean GLboolean GLboolean b
CE_BufferDevice()
Empty buffer constructor.
friend void swap(CE_BufferDevice< T > &a, CE_BufferDevice< T > &b)
const cl::Buffer & allocBuffer() const
const cl::Buffer & buffer() const
bool isEmpty() const
Returns true iff there are no occupied elements in the buffer.
CE_BufferDevice(exint size)
Allocated an uninitialized buffer of specified size (if > 0).
void copyBuffer(const cl::Buffer &src, const cl::Buffer &dst, size_t size, size_t src_offset=0, size_t dst_offset=0)
void matchAndCopyToArray(UT_Array< T > &dst, exint len=-1, bool block=true) const