When an image2d_t created from an OpenGL Renderbuffer is passed to a kernel, the kernel completes instantly without actually running whenever it is enqueued. For example, in the following:
__kernel void sample(__write_only image2d_t output) {
printf("The kernel is being executed.\n");
uint2 pixel = {get_global_id(0), get_global_id(1)};
write_imagef(output, as_int2(pixel), (float4)(1, 1, 1, 1));
}
no text is ever printed to the screen, and the renderbuffer is not written to. I've attached a testcase.
I'm running on 64bit linux, with a Core i5 3570, and a Radeon HD 7970.
Thanks for the testcase. I will look into it, and let you know.
Can you confirm this is a duplicate of http://devgurus.amd.com/message/1299102#1299102
Not a duplicate. Using a renderbuffer the OpenCL kernel is ignored entirely. Using a texture the kernel is run, but only the first write to the texture affects it (when run on CPU).
Can you please go through CL_GL Interop sample from APP SDK. I do not see the usage of GLContext, as present in SimpleGL.cpp. I am myself not very familiar with OpenGL, but as I understand a GL context should also be created.
#ifdef _WIN32
static HWND gHwnd;
HDC gHdc;
HGLRC gGlCtx;
BOOL quit = FALSE;
MSG msg;
#else
GLXContext gGlCtx;
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
Window win;
Display *displayName;
XEvent xev;
#endif
glutInit() handles cross-platform OpenGL context creation.
Sorry for the late reply.
using glut for CL-GL interop is not recommended as there does not seem to be a way to get hold of the GL context from glut API. Can you try to use raw windowing capabilities, and create a testcase. You can refer to SimpleGL sample for testcase creation.