static void OnReleaseDestinationTexture(UInt64 name, IntPtr tokenPtr)
 {
     // TODO: release outputPacket
     using (var token = new GlSyncPoint(tokenPtr)) {
         token.Wait();
     }
 }
Example #2
0
    private void OnTextureFrameRelease(UInt64 textureName, IntPtr syncTokenPtr)
    {
        lock (((ICollection)textureFramesInUse).SyncRoot) {
            if (!textureFramesInUse.TryGetValue(textureName, out var textureFrame))
            {
                Debug.LogWarning("The released texture does not belong to the pool");
                return;
            }

            textureFramesInUse.Remove(textureName);

            if (frameCount > poolSize || IsStale(textureFrame))
            {
                return;
            }

            if (syncTokenPtr != IntPtr.Zero)
            {
                using (var glSyncToken = new GlSyncPoint(syncTokenPtr)) {
                    glSyncToken.Wait();
                }
            }
            availableTextureFrames.Enqueue(textureFrame);
        }
    }
Example #3
0
 // TODO: stop invoking OnRelease when it's already released
 public void Release(GlSyncPoint token = null)
 {
     if (_glSyncToken != null)
     {
         _glSyncToken.Dispose();
     }
     _glSyncToken = token;
     OnRelease.Invoke(this);
 }
Example #4
0
 /// <summary>
 ///   Waits until the GPU has executed all commands up to the sync point.
 ///   This blocks the CPU, and ensures the commands are complete from the point of view of all threads and contexts.
 /// </summary>
 public void WaitUntilReleased()
 {
     if (_glSyncToken == null)
     {
         return;
     }
     _glSyncToken.Wait();
     _glSyncToken.Dispose();
     _glSyncToken = null;
 }