OpenCL/GL Interop

Help
2010-04-22
2012-12-21
  • Douglas Andrade

    Douglas Andrade - 2010-04-22

    Hi, I'm trying to get OpenCL/GL interop using Cloo and OpenTK, but I keep getting a Cloo.ComputeErrorCode.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR error.

    I'm using ATI Stream SDK 2.01 so I think I *should* be able to create a Context from OpenGL but…
    I get the error just as I try to create the ComputeContext Ctx.
    This is the code I try to run:

    OpenTK.Graphics.IGraphicsContextInternal ctx = (OpenTK.Graphics.IGraphicsContextInternal)OpenTK.Graphics.GraphicsContext.CurrentContext;
    
                IntPtr raw_context_handle = ctx.Context.Handle;
    
                ComputeContextProperty p1 = new ComputeContextProperty(ComputeContextPropertyName.CL_GL_CONTEXT_KHR, raw_context_handle);
                ComputeContextProperty p2 = new ComputeContextProperty(ComputeContextPropertyName.Platform, ComputePlatform.Platforms[0].Handle);
                List<ComputeContextProperty> props = new List<ComputeContextProperty>() { p1, p2 };
    
                ComputeContextPropertyList Properties = new ComputeContextPropertyList(props);
    
                try
                {
                    ComputeContext Ctx = new ComputeContext(ComputeDeviceTypes.Gpu, Properties, null, IntPtr.Zero);
                    ComputeErrorCode Error;
    
                    unsafe
                    {
                        Cloo.Bindings.CL10.CreateFromGLBuffer(Ctx.Handle, ComputeMemoryFlags.CopyHostPointer | ComputeMemoryFlags.ReadWrite, bufs[0], &Error);
                    }
                }
                catch {
                    int i = 0;
                }
    

    What am I missing?

    Thanks

     
  • Douglas Andrade

    Douglas Andrade - 2010-04-22

    Can´t edit the post, let me try to use the CODE tag again for the code:

    OpenTK.Graphics.IGraphicsContextInternal ctx = (OpenTK.Graphics.IGraphicsContextInternal)OpenTK.Graphics.GraphicsContext.CurrentContext; IntPtr raw_context_handle = ctx.Context.Handle; ComputeContextProperty p1 = new ComputeContextProperty(ComputeContextPropertyName.CL_GL_CONTEXT_KHR, raw_context_handle); ComputeContextProperty p2 = new ComputeContextProperty(ComputeContextPropertyName.Platform, ComputePlatform.Platforms.Handle); List<ComputeContextProperty> props = new List<ComputeContextProperty>() { p1, p2 }; ComputeContextPropertyList Properties = new ComputeContextProperty[code]OpenTK.Graphics.IGraphicsContextInternal ctx = (OpenTK.Graphics.IGraphicsContextInternal)OpenTK.Graphics.GraphicsContext.CurrentContext;
    IntPtr raw_context_handle = ctx.Context.Handle;
    ComputeContextProperty p1 = new ComputeContextProperty(ComputeContextPropertyName.CL_GL_CONTEXT_KHR, raw_context_handle);
    ComputeContextProperty p2 = new ComputeContextProperty(ComputeContextPropertyName.Platform, ComputePlatform.Platforms[0].Handle);
    List<ComputeContextProperty> props = new List<ComputeContextProperty>() { p1, p2 };
    ComputeContextPropertyList Properties = new ComputeContextPropertyList(props);
    try
    {
    ComputeContext Ctx = new ComputeContext(ComputeDeviceTypes.Gpu, Properties, null, IntPtr.Zero);
    ComputeErrorCode Error;
    unsafe
    {
    Cloo.Bindings.CL10.CreateFromGLBuffer(Ctx.Handle, ComputeMemoryFlags.CopyHostPointer | ComputeMemoryFlags.ReadWrite, bufs[0], &Error);
    }
    }
    catch {
    int i = 0;
    }[/code]
    
     
  • nythrix

    nythrix - 2010-04-22

    Never mind the tags, they don't really work.
    I've tried setting CL/GL interop up before but never succeded :(. I'll have a go with the newest CUDA package from yesterday. I'll post back any results.

     
  • nythrix

    nythrix - 2010-04-23

    Problem partially solved (only windows) here: http://www.opentk.com/node/1722

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks