
Interop OpenCL/OpenGL problem...... :(
Posted Sunday, 11 December, 2011 - 19:37 by Pablitinho inHi,
I am porting the Volume rendering example of NVIDIA to Cloo making use of OpenTK. The issue is that when I acquire the GL object, the buffer size of the variable pbo_cl still 0. Seems that there is not a right Binding..... I am lost and I dont know why this doesn't work. I tested also with textures and the same issue...... Thx in advance....
// Context Creation [DllImport("opengl32.dll")] extern static IntPtr wglGetCurrentDC(); //... IntPtr glHandle = (GraphicsContext.CurrentContext as IGraphicsContextInternal).Context.Handle; IntPtr wglHandle = wglGetCurrentDC(); ComputePlatform platform = ComputePlatform.GetByName("NVIDIA CUDA"); ComputeContextProperty p1 = new ComputeContextProperty(ComputeContextPropertyName.Platform, platform.Handle); ComputeContextProperty p2 = new ComputeContextProperty(ComputeContextPropertyName.CL_GL_CONTEXT_KHR, glHandle); ComputeContextProperty p3 = new ComputeContextProperty(ComputeContextPropertyName.CL_WGL_HDC_KHR, wglHandle); ComputeContextPropertyList cpl = new ComputeContextPropertyList(new ComputeContextProperty[] { p1, p2, p3 }); ComputeContext context = new ComputeContext(ComputeDeviceTypes.Gpu, cpl, null, IntPtr.Zero);
CL.ComputeBuffer<uint> pbo_cl; ComputeEventList ev = new ComputeEventList(); GL.Arb.GenBuffers(1, out pbo); GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, pbo); GL.Arb.MapBuffer(BufferTargetArb.ArrayBuffer, ArbVertexBufferObject.StreamDrawArb); GL.Arb.BufferData(BufferTargetArb.ArrayBuffer, (IntPtr)(512* 512* 4*sizeof(byte)), IntPtr.Zero, BufferUsageArb.StreamDraw); GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, 0); pbo_cl = ComputeBuffer<uint>.CreateFromGLBuffer<uint>(oclContext, ComputeMemoryFlags.WriteOnly, (int)pbo); List<ComputeMemory> PBO_CL = new List<ComputeMemory>() { pbo_cl }; GL.Flush(); GL.Finish(); oclCQ.AcquireGLObjects(PBO_CL, ev); // After this... pbo_cl size continue to 0. //OPENCL Calls..... oclCQ.ReleaseGLObjects(PBO_CL, ev); oclCQ.Finish();


Comments
Re: Interop OpenCL/OpenGL problem...... :(
This is a piece of code from one of my testing programs. And it does work:
I use the GCHandle because VBO is not just plain numbers. Other than that I have no special code around.
Try a couple of things:
1) driver sanity check
2) see that opengl is properly initialized
3) check pbo initialization
Re: Interop OpenCL/OpenGL problem...... :(
Thx Nythrix,
Now it's working ok. It was a PICNIC.
Regards,
Pablo.