Ejemplo n.º 1
0
 private static void OnCommandBufferCompleted_Static(IntPtr block, MTLCommandBuffer cb)
 {
     lock (s_aotRegisteredBlocks)
     {
         if (s_aotRegisteredBlocks.TryGetValue(block, out MTLGraphicsDevice gd))
         {
             gd.OnCommandBufferCompleted(block, cb);
         }
     }
 }
Ejemplo n.º 2
0
        private protected override void WaitForIdleCore()
        {
            MTLCommandBuffer lastCB = default(MTLCommandBuffer);

            lock (_submittedCommandsLock)
            {
                lastCB = _latestSubmittedCB;
            }

            if (lastCB.NativePtr != IntPtr.Zero && lastCB.status != MTLCommandBufferStatus.Completed)
            {
                lastCB.waitUntilCompleted();
            }
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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);
        }