- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm getting a NULL cl_mem value.. but CL_SUCCESS as an error code. I'm on x86_64 Arch Linux with Intel® Iris™ Pro Graphics 5200. This is the code I'm trying to run:
#includeIs this a bug? Thanks!#include #include #include static int WINDOW_WIDTH = 800; static int WINDOW_HEIGHT = 600; int main() { cl_int err; cl_platform_id platform; if (clGetPlatformIDs(1, &platform, NULL) != CL_SUCCESS) { fprintf(stderr, "error getting platforms\n"); return 1; } cl_device_id device; if(clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 1, &device, NULL) != CL_SUCCESS) { fprintf(stderr, "error getting devices\n"); return 1; } cl_context context = clCreateContext(NULL, 1, &device, NULL, NULL, &err); SDL_Window* w = SDL_CreateWindow("Oh hello, mandelbrot", 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0); SDL_GL_CreateContext(w); GLint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, WINDOW_WIDTH, WINDOW_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL ); if(glGetError() != GL_NO_ERROR) { fprintf(stderr, "OpenGL error\n"); return 2; } cl_mem img = clCreateFromGLTexture2D( context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, tex, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "OpenCL error creating image: %d\n", err); return 1; } else if (img == NULL) { fprintf(stderr, "NULL image\n"); return 1; } return 0; }
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
you should create shared GL-CL context first: https://software.intel.com/en-us/articles/opencl-and-opengl-interoperability-tutorial
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
you should create shared GL-CL context first: https://software.intel.com/en-us/articles/opencl-and-opengl-interoperability-tutorial
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh good to know!
Turns out my problem is even simpler than that, though.. Apparently cl_khr_gl_sharing isn't supported on my device.
Thanks!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page