Results 1 to 3 of 3

Thread: [OS X, CoreImage]How to bind a CIImage to an openCL image2d?

  1. #1

    [OS X, CoreImage]How to bind a CIImage to an openCL image2d?

    Hi,

    I guess a lot of you are coding on a Mac, so I've got a simple question for you.

    I've got a CIImage (CoreImage framework) which is already on the GPU memory. So far, I transfer the CIImage into a NSBitmapImageRep on the CPU memory before resending back to the GPU memory in an OpenCL image2d.
    Yes, it sounds stupid but I don't know how to do otherwise
    How to create (or bind) an OpenCL image2d directly from a CIImage?

    I know that a CIImage can be transformed into an openGL texture, an openGL texture can be bound with a IOSurface and then an IOSurface can be bound to an openCL image2d.
    Has anyone already tried to do something like that or have a pointer to some sample code?

    Thanks for your help!

    Vincent

  2. #2
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: [OS X, CoreImage]How to bind a CIImage to an openCL imag

    I would recommend the following:

    1) First of all, you need to create a CL context from a CGLShareGroup. You can get the CGLShareGroup by doing:

    CGLShareGroupObj sharegroup = CGLGetShareGroup((CGLContextObj)[[NSOpenGLContext currentContext] CGLContextObj]);

    cl_context_properties akProperties[] = { CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (cl_context_properties)sharegroup, 0 };

    context = clCreateContext(akProperties, 0, 0, clLogMessagesToStdoutAPPLE, 0, &err);

    2) Then create the CIImage from a GL texture.

    3) Then create the CL image from the GL texture using the CL API call clCreateImage2D (assuming it is a 2D texture).

    If you want to use IOSurfaces, then you can use the clCreateImageFromIOSurface2DAPPLE API in Lion. This creates a CL image from an IOsurface.

  3. #3

    Re: [OS X, CoreImage]How to bind a CIImage to an openCL imag

    Thanks Affie,

    What you propose works well
    Since I wanted to convert the CIImage in OpenCL, first I rendered the CIImage in the OpenGL texture (using FBO) and then I created my CIImage from the OpenGL texture.
    It seems that the whole process is about 2ms which is very good.

    I could not solve this without your help.
    Thank you very much.

    Cheers,

    Vincent

Similar Threads

  1. How to bind an OpenCL image 2d to a ci_image?
    By vincentfpgarcia in forum OpenCL
    Replies: 1
    Last Post: 01-08-2012, 01:12 PM
  2. Replies: 2
    Last Post: 01-04-2010, 12:58 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
  •