Results 1 to 4 of 4

Thread: Is there a way to GL render 3d data directly from CL memory?

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    16

    Is there a way to GL render 3d data directly from CL memory?

    Anybody know if there is any way to render 3d vertex data directly from a CL memory buffer, without copying to host memory and back?

    For example, if I compute a surface of 3d coordinates using OpenCL, and then want to visualize this using GL with lighting, camera, etc.

    I can copy the data to the host and then feed it back via individual GL vertex calls, but it seems if the data could remain on the graphics card this could be much faster. There is a way to move CL memory directly to GL texture memory, so I'm hoping something like that might exist for vertex/polygon data as well...

    Thanks!

  2. #2

    Re: Is there a way to GL render 3d data directly from CL memory?

    I vaguely remember NVIDIA having an example that did this. It moved points in a sin-wave and rendered using OpenGL. In any case, it certainly is possible and you should read sections 9.11 and 9.12 in the OpenCL specification.

  3. #3

    Re: Is there a way to GL render 3d data directly from CL mem

    I don't have enough experience with sharing graphics contexts with OpenCL, but with CUDA what you do is share a vertex buffer object (VBO) and write the vertices to the VBO which you can then send to OpenGL for rendering instead of passing the vertices one by one from the CPU.

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

    Re: Is there a way to GL render 3d data directly from CL mem

    Refer to section 9.7 of the 1.1 spec which describes how to create a CL context for sharing with GL. You can pass a GLcontext or a sharegroup (on Mac OS X) to cl_context_properties argument in clCreateContext.

    Once you have a CL context that is associated with a GL context or sharegroup, then to share a VBO, renderbuffer or texture, all you do is create the cl_mem object using the clCreateFromGLBuffer, clCreateFromGLRenderbuffer or clCreateFromGLTexture{2D | 3D} APIs. The cl_mem object and the GL object both share the same data so there are no copies.

    To use a cl_mem object created from a GL object inside CL, you need to call clEnqueueAcquireGLObjects and once you are doing using these objects you call clEnqueueReleaseGLObjects. You can also do fine grained sharing by creating a cl_event from a GLsync object and vice-versa. All of this is described in sections 9.8 and 9.9 of the 1.1 spec.

Similar Threads

  1. WebGL directly from Maya
    By jochen_0x90h in forum Toolkits, SDKs, wrappers, libraries
    Replies: 2
    Last Post: 12-20-2011, 01:47 AM
  2. Write to Framebuffer directly
    By mnarkhede in forum OpenVG and VGU
    Replies: 4
    Last Post: 05-12-2008, 06:59 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
  •