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); } }
static void OnReleaseDestinationTexture(UInt64 name, IntPtr tokenPtr) { // TODO: release outputPacket using (var token = new GlSyncPoint(tokenPtr)) { token.Wait(); } }
/// <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; }