You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.5 KiB
35 lines
1.5 KiB
#include <CL/cl.h>
|
|
#include <CL/cl_gl.h>
|
|
#include <CL/cl_egl.h>
|
|
#include <CL/cl_ext.h>
|
|
#include <CL/cl_gl_ext.h>
|
|
#include <dlfcn.h>
|
|
|
|
|
|
void* libHandle = nullptr;
|
|
|
|
#define FUNC_TYPES(rettype, fname, fargs, callArgs) \
|
|
typedef rettype (* fname ## _t) fargs;
|
|
|
|
#define FUNC_SYM(rettype, fname, fargs, callArgs) \
|
|
rettype fname fargs { \
|
|
if (!libHandle) \
|
|
libHandle = dlopen( "libOpenCL.so", RTLD_NOW | RTLD_GLOBAL ); \
|
|
\
|
|
static fname ## _t func = nullptr; \
|
|
if (!func) \
|
|
func = reinterpret_cast< fname ## _t >(dlsym(libHandle, #fname)); \
|
|
\
|
|
return func callArgs; \
|
|
\
|
|
}
|
|
|
|
#define CL_MACRO FUNC_TYPES
|
|
#include "apis.h"
|
|
#undef CL_MACRO
|
|
|
|
#define CL_MACRO FUNC_SYM
|
|
#include "apis.h"
|
|
#undef CL_MACRO
|
|
|