Results 1 to 6 of 6

Thread: Sharing OpenGL object with OpenCL and use CPU device ?

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    14

    Sharing OpenGL object with OpenCL and use CPU device ?

    Is it possible to share OpenGL objects with OpenCL and use OpenCL CPU device if the GPU is not supported by OpenCL ?

  2. #2

    Re: Sharing OpenGL object with OpenCL and use CPU device ?

    I don't think so, mainly because if I create a OpenCL context that shares the CPU isn't given as a compute device. That's on a Snow Leopard Mac with a NV8600.

    I assume you'd be unable to create a shared OpenCL context on a machine that had an unsupported GPU, but I've yet to try it as I haven't updated my older ATI based machine yet to try anything.

  3. #3
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Sharing OpenGL object with OpenCL and use CPU device ?

    This will depend entirely on the system you're using as the CL/GL interop is up to the vendor.

    On SnowLeopard I believe you can do this if you create your context in a special manner. (You need to specify the Apple CL/GL sharing extension property and then pass in the CPU device explicitly, or something, but I don't remember the details.) Take a look at Apple's documentation and see if they have an example. It might even be documented in the header file.

  4. #4
    Junior Member
    Join Date
    Sep 2009
    Posts
    14

    Re: Sharing OpenGL object with OpenCL and use CPU device ?

    I have found the solution under Snow Leopard

    CGLContextObj kCGLContext = [openglContext CGLContextObj];
    CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);

    // Create a context from a CGL share group
    cl_context_properties properties[] = { CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (cl_context_properties)kCGLShareGroup, 0 };

    context = clCreateContext(properties, 0, 0, 0, 0, 0);
    if (!context)
    {
    NSLog(@"Error: Failed to create a compute context!\n");
    return NO;
    }

    size_t returned_size;
    unsigned int device_count;
    cl_device_id device_ids[16];

    err = clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeof(device_ids), device_ids, &returned_size);
    if (err)
    {
    NSLog(@"Error: Failed to retrieve compute devices for context!\n");
    return NO;
    }

  5. #5
    Junior Member
    Join Date
    Sep 2009
    Posts
    14

    Re: Sharing OpenGL object with OpenCL and use CPU device ?

    One other information.
    It seem's that when you try to share an OpenGL context with an OpenCL context, only GPU are returned.

    I don't have found any solution to use CPU device in this case.

  6. #6
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Sharing OpenGL object with OpenCL and use CPU device ?

    Try getting the CPU device and passing it in when you call clCreateContext with the properties. I believe this will add the CPU device to your context along with the appropriate GPU device, but it's been a while since I tried this.

Similar Threads

  1. Replies: 3
    Last Post: 05-12-2010, 03:09 PM
  2. Sharing Renderbuffer OpenGL object with OpenCL
    By YOYOSENIOR in forum OpenCL
    Replies: 2
    Last Post: 09-14-2009, 04:41 AM

Posting Permissions

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