private static void OnCommandBufferCompleted_Static(IntPtr block, MTLCommandBuffer cb) { lock (s_aotRegisteredBlocks) { if (s_aotRegisteredBlocks.TryGetValue(block, out MTLGraphicsDevice gd)) { gd.OnCommandBufferCompleted(block, cb); } } }
private protected override void WaitForIdleCore() { MTLCommandBuffer lastCB = default(MTLCommandBuffer); lock (_submittedCommandsLock) { lastCB = _latestSubmittedCB; } if (lastCB.NativePtr != IntPtr.Zero && lastCB.status != MTLCommandBufferStatus.Completed) { lastCB.waitUntilCompleted(); } }
private protected override void SubmitCommandsCore(CommandList commandList, Fence fence) { MTLCommandList mtlCL = Util.AssertSubtype <CommandList, MTLCommandList>(commandList); mtlCL.CommandBuffer.addCompletedHandler(_completionBlockLiteral); lock (_submittedCommandsLock) { if (fence != null) { MTLFence mtlFence = Util.AssertSubtype <Fence, MTLFence>(fence); _submittedCBs.Add(mtlCL.CommandBuffer, mtlFence); } _latestSubmittedCB = mtlCL.Commit(); } }
private protected override void SwapBuffersCore(Swapchain swapchain) { MTLSwapchain mtlSC = Util.AssertSubtype <Swapchain, MTLSwapchain>(swapchain); IntPtr currentDrawablePtr = mtlSC.CurrentDrawable.NativePtr; if (currentDrawablePtr != IntPtr.Zero) { using (NSAutoreleasePool.Begin()) { MTLCommandBuffer submitCB = _commandQueue.commandBuffer(); submitCB.presentDrawable(currentDrawablePtr); submitCB.commit(); } } mtlSC.GetNextDrawable(); }
private void OnCommandBufferCompleted(IntPtr block, MTLCommandBuffer cb) { lock (_submittedCommandsLock) { if (_submittedCBs.TryGetValue(cb, out MTLFence fence)) { fence.Set(); _submittedCBs.Remove(cb); } if (_latestSubmittedCB.NativePtr == cb.NativePtr) { _latestSubmittedCB = default(MTLCommandBuffer); } } ObjectiveCRuntime.release(cb.NativePtr); }