OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.

NULL image from clCreateFromGLTexture2D

Ben_F_1
Beginner
484 Views
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:
#include #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; }
Is this a bug? Thanks!
0 Kudos
1 Solution
2 Replies
Maxim_S_Intel
Employee
485 Views
0 Kudos
Ben_F_1
Beginner
484 Views

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!

0 Kudos
Reply