/// <summary> /// Enqueues a command to release <see cref="ComputeMemory"/>s that have been created from OpenGL objects. /// </summary> /// <param name="memObjs"> A collection of <see cref="ComputeMemory"/>s that correspond to OpenGL memory objects. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="ComputeEvent"/> identifying this command is created and attached to the end of the collection. </param> public void ReleaseGLObjects(ICollection <ComputeMemory> memObjs, ICollection <ComputeEventBase> events) { int memObjCount; CLMemoryHandle[] memObjHandles = ComputeTools.ExtractHandles(memObjs, out memObjCount); int eventWaitListSize; CLEventHandle[] eventHandles = ComputeTools.ExtractHandles(events, out eventWaitListSize); bool eventsWritable = (events != null && !events.IsReadOnly); CLEventHandle[] newEventHandle = (eventsWritable) ? new CLEventHandle[1] : null; ComputeErrorCode error = CL10.EnqueueReleaseGLObjects(Handle, memObjCount, memObjHandles, eventWaitListSize, eventHandles, newEventHandle); ComputeException.ThrowOnError(error); if (eventsWritable) { events.Add(new ComputeEvent(newEventHandle[0], this)); } }
/// <summary> /// Enqueues a command to release <see cref="OpenCLMemory"/>s that have been created from OpenGL objects. /// </summary> /// <param name="memObjs"> A collection of <see cref="OpenCLMemory"/>s that correspond to OpenGL memory objects. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> public void ReleaseGLObjects(IList <OpenCLMemory> memObjs, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null) { int memObjCount; CLMemoryHandle[] memObjHandles = OpenCLTools.ExtractHandles(memObjs, out memObjCount); int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; OpenCLErrorCode error = CL10.EnqueueReleaseGLObjects(Handle, memObjCount, memObjHandles, eventWaitListSize, eventHandles, newEventHandle); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } }