Results 1 to 9 of 9

Thread: cl_out_of_resources

  1. #1


    Hello forum,

    I am getting the above while creating texture object from the opengl buffer object. I checked the opencl context creation with opengl-opencl interoperability and the context creation gave me cl_success.

    Where should i look into now ?

    Any hint?


  2. #2
    Hi Forum,

    Let me elaborate more. I checked the 1.1 specification because my card so far support 1.1.

    Everywhere in the spec it mentions that we usually get CL_OUT_OF_RESOURCES error for the following reason:

    "if there is a failure to allocate resources required by the
    OpenCL implementation on the device."

    What type of resources are there. They are never mentioned . are memory, context, - what are these resources

    Any one would like to step forward to explain ?

    When do we usually get this type of error?


  3. #3
    Hello forum,

    No response so far. I believe i was not clear enough to you guys . Let me try again.

    I am having the above error "CL_OUT_OF_RESOURCES" while creating the OpenCL buffer from the OpenGL Texture Object. Any idea what might have caused this type of error. I have created the texture object with internal format "GL_RGBA32F_ARB" and according to the 1.1 specification it is mappable to the corresponding opencl type CL_RGBA. The texture object's source format is "GL_RGBA" and source type is "GL_FLOAT".

    I have created the OpenCL context with CL-GL interoperability and the context creation gave me CL_SUCCESS. So i can be assured that the context creation is successful. What do you think ?

    I shall be eagerly waiting for your hint over this issue. Let me know if you need more details.


  4. #4
    Senior Member
    Join Date
    Oct 2012
    If you use NVIDIA hardware, CL_OUT_OF_RESOURCES is a kind of "generic" error returned by the driver when something is wrong. As a result, it is not necessarily a real "Out of resources" problem.

    For instance, calling clCreateFromGLTexture2D() with an invalid texture ID will often return CL_OUT_OF_RESOURCES with an NVIDIA driver whereas it will return CL_INVALID_GL_OBJECT with an AMD or Intel driver.

    You state that you create an OpenCL buffer from an OpenGL texture object. However you can only create an OpenCL image from an OpenGL texture object.

  5. #5
    Sorry for for the typo. I am actually trying to create OpenCL Image from the OpenGL texture object. I have checked the texture creation and it shows that is has been created successfully .

    Any other hint to look into ?


  6. #6
    Senior Member
    Join Date
    Oct 2012
    Do you use the GL_RGBA32F internal format for the texture? If so, it would be worth you post the part of your code that exhibits the problem.

  7. #7
    Thanks for the initiative. Here goes the code snippet where i am initializing the texture :

    Code :
       //declare a 2D OpenCL Texture
       osg::ref_ptr<osgOpenCL::Texture2D> trgTexture = new osgOpenCL::Texture2D;
       trgTexture->setName("Target Texture");
       //set the internel format for the for the target texture
       trgTexture->setInternalFormat( GL_RGBA32F_ARB );
       trgTexture->setSourceFormat( GL_RGBA );
       trgTexture->setSourceType( GL_FLOAT );
       //define the texture width and height of the
       //target texture

    By the way i am attaching OpenSceneGraph and OpenCL together.

    Then i am trying to allocate opencl image from the texture object that i have created :

    Code :
    	 //pull out the texture object
    	 osg::Texture::TextureObject *tex = _texref->getTextureObject(osgCompute::GLMemory::getContext()->getState()->getContextID());
    	    //get the current osg state of the current GL memory context
    	    osg::State *state = osgCompute::GLMemory::getContext()->getState();
    	    //make sure that the state is extracted
    	    if(state == NULL)
    	       osg::notify(osg::FATAL) << __FUNCTION__ << " " << _texref->getName() << ": unable to find valid state." << std::endl;
    	       return false;
    	    //calls apply() to compile the texture
    	    //unbind the texture after compilation
    	    //returns and store the pointer to the texture object of the current context
    	    tex = _texref->getTextureObject(osgCompute::GLMemory::getContext()->getState()->getContextID());
    	 //now register the buffer object for opencl
    	 //get the texture target
    	 GLenum texture_target = tex->_profile._target;
    	 //create buffer based on the texture target
    	 if( texture_target == GL_TEXTURE_2D || texture_target == GL_TEXTURE_RECTANGLE )
    	    (memory._m_clGraphicsArrayBuffer) = clCreateFromGLTexture2D(cxt->_m_clContext,
    	    if(errNum != CL_SUCCESS)
    	       osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__ << ": " << _texref->getName()
    				       << ": unable to pull out the 2D OpenCL texture memory from the OpenGL memory: "
    				       << cxt->getErrorString(errNum)  << std::endl;
    	       return false;

    I am always getting the error message " osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__ << ": " << _texref->getName()
    << ": unable to pull out the 2D OpenCL texture memory from the OpenGL memory: "
    << cxt->getErrorString(errNum) << std::endl;"

    Was it informative enough ?


  8. #8
    Senior Member
    Join Date
    Oct 2012
    I'm not sure that this is the main reason for your error, but the OpenGL texture must be filled with pixel data before being used with OpenCL.
    If you call glTexImage2D() with a null pixels pointer, OpenCL will not allocate OpenGL memory and you will either get an error or a wrong result. Try to create the OpenGL texture with a data buffer filled with 0.0f values.

  9. #9

    I am have a sample small application from the OpenCL programming guide and they have defined the texture completeness as follows:

    Code :
    void initTexture( int width, int height )
       // make a texture for output
       glGenTextures(1, &tex);              // texture 
       glBindTexture(GL_TEXTURE_RECTANGLE_ARB, tex);
       glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA32F_ARB, width,
    		height, 0, GL_LUMINANCE, GL_FLOAT, NULL );
       glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

    As you can see that glTexImage2D(...) points to NULL pixel data. My question is that if the data pointer is NULL in glTexImage2D(...) will the texture not be complete ?

    And the sample applications works fine at my side. You could check it as well .

    I would like to know what do the OpenCL resource contain ? When we get the error "CL_OUT_OF_RESOURCES", what resources does it exactly imply ?

    Any more thoughts ?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts