11 #ifndef __CE_Context__
12 #define __CE_Context__
40 virtual
void rebindOGLBuffer(
uint buf_obj ) = 0;
41 virtual
void unbindOGLBuffer() = 0;
42 virtual
bool isBinded() = 0;
72 const cl_image_desc *desc,
79 #ifndef CL_UUID_SIZE_KHR
80 #define CL_UUID_SIZE_KHR 16
99 static CE_Context *getContext(
bool gl_shared =
true,
100 bool shared_fallback =
true);
102 static bool isGLSharingPossible();
125 void get1DRanges(
const cl::Kernel &k,
size_t items,
130 void getReductionRanges(
const cl::Kernel &k,
size_t items,
size_t accumsize,
132 uint &groupsize,
uint &ngroups)
const;
135 size_t getMaxWorkgroupSize(
const cl::Kernel &k);
138 std::vector<size_t> getMaxWorkItemSizes();
144 static size_t roundUpGroupSize(
size_t gsize);
154 const char *options =
nullptr,
155 bool recompile =
false);
157 const char *options =
nullptr,
158 bool recompile =
false);
166 const char *options =
nullptr)
167 {
return loadKernel(loadProgram(progname, options), kernelname); }
175 static bool isInitialized(
bool gl_shared=
false);
189 void finish(
bool sweep_pool=
true);
211 size_t src_offset = 0,
size_t dst_offset = 0);
218 size_t src_offset = 0);
225 size_t dst_offset = 0);
235 void unregisterDelayedOGLBindBuffer(
uint32 id);
251 bool supportsExternalMemory();
264 const cl_image_desc& image_desc,
265 bool read =
true,
bool write =
true);
268 void clearMemoryPool();
274 void sweepInUseMemory();
299 static void reportError(
const cl::Error &err);
300 static void outputErrorMessage(
const char *err_msg);
302 static void outputWarningMessage(
const char *err_msg);
304 static void initMainSharedGLContext(
int devicetype,
void* context,
void* display,
const cl_uchar (&uuid)[16]);
305 static bool useHalfNormalDelayedBindBuffer();
313 static bool shouldUseOCLOGLInterop();
330 static int getDefaultDevice(
334 static bool isEnvironmentOverride();
348 size_t getAddressableMemory()
const;
351 void reportUsage(std::ostream &os)
const;
355 int64 requestMemoryFromResource(
int64 amount);
361 return myMemResource;
365 cl::Program *doCompileProgram(
const char *progtext,
const char *options,
372 void releasePinnedBuffer();
408 static char theGLDeviceUUID[16];
416 const std::vector<cl::Event>* events,
struct _cl_device_id * cl_device_id
bool has3DImageWriteSupport() const
Returns true if the OpenCL device supports writing to 3D image objects.
GLenum GLuint GLenum GLsizei const GLchar * buf
cl::Device getDevice() const
Returns the OpenCL Device object.
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
bool myOutOfMemoryFailure
UT_StringHolder platformVendor
bool mySupports3DImageWrites
ceTraceCtx getTraceContext() const
CE_API cl_int ce_enqueueKernel(const cl::CommandQueue &queue, const cl::Kernel &kernel, const cl::NDRange &offset, const cl::NDRange &global, const cl::NDRange &local, const std::vector< cl::Event > *events, cl::Event *event)
**But if you need a result
virtual ~CE_DelayedOGLBindBuffer()
cl::CommandQueue getQueue() const
Event interface for cl_event.
bool isValid() const
Returns whether the CE_Context has been successfully initialized.
UT_StringHolder driverVersion
UT_Map< uint32, CE_DelayedOGLBindBuffer * > myDelayedOGLBindBuffers
cl_bitfield cl_device_type
cl::CommandQueue myDeviceQueue
GLint GLint GLsizei GLint GLenum format
CE_MemoryPool * myMemPool
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the queue
static void * theGLDisplay
void setOutOfMemoryFailure(bool hasfailed=true)
CommandQueue interface for cl_command_queue.
static void * theGLContext
cl_int getInfo(Func f, cl_uint name, T *param)
cl::Kernel loadKernel(const char *progname, const UT_StringRef &kernelname, const char *options=nullptr)
CE_DelayedOGLBindBuffer()
UT_MemoryResource * getMemoryResource() const
Base class interface for all images.
void(* CE_ErrorCB)(const char *errmsg, UT_ErrorSeverity severity, void *data)
Kernel interface that implements cl_kernel.
cl::Context getCLContext() const
Returns the underlying cl::Context object.
UT_MemoryResource * myMemResource
static int theGLDeviceType
UT_Map< const _cl_program *, UT_Array< KernelInfo > * > myKernelTable
Device interface for cl_device_id.
bool hasDoubleSupport() const
Returns true if the OpenCL device supports double precision.
Program interface that implements cl_program.
bool hasOutOfMemoryFailureHappened() const
cl::Buffer myPinnedBuffer
UT_StringMap< cl::Program * > myProgramTable