예제 #1
0
        ///<summary>
        ///Encounter a command to acquire a collection of <see cref = "ComputeMemory"/> s that have been created previously from created OpenGL objects.
        ///</summary>
        ///<param name = "memObjs"> A collection of OpenCL memory objects that correspond to OpenGL objects. </param>
        ///<paramref name = "events"/> is not <c> null </c> or read-only a new <param name = "events"> A collection of events that need to complete before this command   <see cref = "ComputeEvent"/> identifying this command is created and attached to the end of the collection. </param>
        public void AcquireGLObjects(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 = ComputeErrorCode.Success;

            error = CL12.EnqueueAcquireGLObjects(Handle, memObjCount, memObjHandles, eventWaitListSize, eventHandles, newEventHandle);
            ComputeException.ThrowOnError(error);

            if (eventsWritable)
            {
                events.Add(new ComputeEvent(newEventHandle[0], this));
            }
        }