danbartlett@ntlworld.com

clCreateFromGLTexture2D + GL textures without mipmaps

Discussion created by danbartlett@ntlworld.com on Jul 18, 2010
Latest reply on Jul 30, 2010 by danbartlett@ntlworld.com

If you create a GL texture, then try to create a CL image from this texture, it seems to fail unless the GL texture has mipmaps.

clCreateFromGLTexture2D also returns error -4 (CL_MEM_OBJECT_ALLOCATION_FAILURE) which isn't listed in the spec as a possible error for this function.

 

// ------------ fails ------------- glGenTextures(1, &GLTex); glBindTexture(GL_TEXTURE_2D, GLTex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); mem = clCreateFromGLTexture2D(CLContext, CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, GLTex, &errcode); // errCode is -4 (CL_MEM_OBJECT_ALLOCATION_FAILURE) // ------------ succeeds ------------- glGenTextures(1, &GLTex); glBindTexture(GL_TEXTURE_2D, GLTex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); // <==== mem = clCreateFromGLTexture2D(CLContext, CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, GLTex, &errcode); // errCode is 0 (CL_SUCCESS)

Outcomes