jstier

OpenCL / OpenGL interoperability

Discussion created by jstier on Dec 23, 2009
Latest reply on Jul 9, 2011 by tonyo_au

Is there an example somewhere that demonstrates OpenCL/OpenGL interoperability with the latest ATI Stream Sdk 2.0. I have done some code searches on the samples for clCreateFromGLTexture2D, clCreateFromGLBuffer and the likes, but I couldn't find anything. Am I under the right impression that the latest sdk has interoperability as a preview feature?

 

In any case, I am creating the OpenCL context after creating the OpenGL context using

 

[code]

cl_context_properties lProperties[] = {

CL_CONTEXT_PLATFORM, (cl_context_properties)lPlatform,

CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),

CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),

0

};

sContextCL = clCreateContextFromType(lProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &sStatus);

[/code]

 

Then I create an OpenGL texture using

 

[code]

glGenTextures(1, &lTextureID);

glBindTexture(GL_TEXTURE_2D, lTextureID);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGB, GL_FLOAT, 0);

glBindTexture(GL_TEXTURE_2D, 0);

 [/code]

 

And then, evey call to clCreateFromGLTexture2D returns CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, no matter what texture format I use. I tried GL_FLOAT, GL_UNSIGNED_INT, GL_UNSIGNED_BYTE etc.

 

[code]

mBufferCL = clCreateFromGLTexture2D(sContextCL, CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, lTextureID, &sStatus);

[/code]

 

If anyone could point me to a compliable demo, that would be very helpful.

Plus, what tag do I use to enter source code into a post ?

 

Cheers

 

 

 

Outcomes