Hi,
I am having difficulties passing a Texture from OpenGL to OpenCL and back.
When I’m setting the kernel argument to be the cl_mem corresponding to the OpenGL Texture I get the Error:
CL_INVALID_MEM_OBJECT
but I can’t figure out why. The doc is not very specific: “an argument declared to be a memory object when the specified arg_value is not a valid memory object”
So my cl_mem is not accepted as an 2D image object.
I’m guessing i created it poorly?
Here are the important snippets of my code:
//helper class
class FrameBuffer{
public:
GLuint glTextureID; //ID to point to corresponding GL Texture
cl_mem clTextureMem; //CL_mem pointer to openCL Memory
};
//creating the Framebuffer:
frameBufferTest = *new FrameBuffer();
//generate the texture ID
glGenTextures(1, &frameBufferTest.glTextureID);
//binnding the texture
glBindTexture(GL_TEXTURE_2D, frameBufferTest.glTextureID);
//regular sampler params
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//specify texture dimensions, format etc
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_FLOAT, 0);
frameBufferTest.clTextureMem = clCreateFromGLTexture(context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0,frameBufferTest.glTextureID,NULL);
CheckError(error, __LINE__);
//Setting the kernel Arguments:
glFinish();
clEnqueueAcquireGLObjects(cq, 1, &frameBufferTest.clTextureMem, 0, 0, NULL);
error = clSetKernelArg(kernels[kernelId], argIdx, sizeof(frameBufferTest.clTextureMem), &frameBufferTest.clTextureMem);//Here i get the Error
CheckError(error, memId);
Maybe you can spot what i did wrong?
Thanks for reading,
Cery