11 #ifndef __CE_Context__
12 #define __CE_Context__
43 virtual
void rebindOGLBuffer(
uint buf_obj ) = 0;
44 virtual
void unbindOGLBuffer() = 0;
45 virtual
bool isBinded() = 0;
75 const cl_image_desc *desc,
82 #ifndef CL_UUID_SIZE_KHR
83 #define CL_UUID_SIZE_KHR 16
102 static CE_Context *getContext(
bool gl_shared =
true,
103 bool shared_fallback =
true);
105 static bool isGLSharingPossible();
128 void get1DRanges(
const cl::Kernel &k,
size_t items,
133 void getReductionRanges(
const cl::Kernel &k,
size_t items,
size_t accumsize,
135 uint &groupsize,
uint &ngroups)
const;
138 size_t getMaxWorkgroupSize(
const cl::Kernel &k);
141 std::vector<size_t> getMaxWorkItemSizes();
147 static size_t roundUpGroupSize(
size_t gsize);
157 const char *options =
nullptr,
158 bool recompile =
false);
164 const char *options =
nullptr,
165 bool recompile =
false,
166 const char *progname =
nullptr);
174 const char *options =
nullptr)
175 {
return loadKernel(loadProgram(progname, options), kernelname); }
183 static bool isInitialized(
bool gl_shared=
false);
197 void finish(
bool sweep_pool=
true);
219 size_t src_offset = 0,
size_t dst_offset = 0);
226 size_t src_offset = 0);
233 size_t dst_offset = 0);
243 void unregisterDelayedOGLBindBuffer(
uint32 id);
259 bool supportsExternalMemory();
272 const cl_image_desc& image_desc,
273 bool read =
true,
bool write =
true);
276 void clearMemoryPool();
282 void sweepInUseMemory();
307 static void reportError(
const cl::Error &err);
308 static void outputErrorMessage(
const char *err_msg);
310 static void outputWarningMessage(
const char *err_msg);
312 static void initMainSharedGLContext(
int devicetype,
void* context,
void* display,
const cl_uchar (&uuid)[16]);
313 static bool useHalfNormalDelayedBindBuffer();
321 static bool shouldUseOCLOGLInterop();
338 static int getDefaultDevice(
342 static bool isEnvironmentOverride();
356 size_t getAddressableMemory()
const;
359 void reportUsage(std::ostream &os)
const;
363 int64 requestMemoryFromResource(
int64 amount);
369 return myMemResource;
374 const char *progname,
375 const char *progtext,
383 void releasePinnedBuffer();
392 bool mySupportsDouble;
393 bool mySupports3DImageWrites;
418 bool myOutOfMemoryFailure;
422 static void* theGLContext;
423 static void* theGLDisplay;
424 static int theGLDeviceType;
425 static char theGLDeviceUUID[16];
433 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
UT_StringHolder platformVendor
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
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Event interface for cl_event.
bool isValid() const
Returns whether the CE_Context has been successfully initialized.
UT_StringHolder driverVersion
cl_bitfield cl_device_type
GLint GLint GLsizei GLint GLenum format
#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
void setOutOfMemoryFailure(bool hasfailed=true)
GLuint const GLchar * name
CommandQueue interface for cl_command_queue.
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.
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