// Flush existing commands and release the current context public long Finish(bool waitForCompletion = false) { Debug.Assert(_Type == CommandListType.Direct || _Type == CommandListType.Compute); FlushResourceBarriers(); //TODO : EngineProfiling Debug.Assert(_CurrentAllocator != null); var queue = Globals.CommandManager.Queue(_Type); var fenceValue = queue.ExecuteCommandList(_CommandList); queue.DiscardAllocator(fenceValue, _CurrentAllocator); _CurrentAllocator = null; _CpuLinearAllocator.CleanUpPages(fenceValue); _GpuLinearAllocator.CleanUpPages(fenceValue); _DynamicViewDescriptorHeap.CleanupUsedHeaps(fenceValue); _DynamicSamplerDescriptorHeap.CleanupUsedHeaps(fenceValue); if (waitForCompletion) { CommandListManager.WaitForFence(fenceValue); } Globals.ContextManager.FreeContext(this); return(fenceValue); }
// Flush existing commands to the GPU but keep the context alive public long Flush(bool waitForCompletion = false) { FlushResourceBarriers(); Debug.Assert(_CurrentAllocator != null); var fenceValue = Globals.CommandManager.Queue(_Type).ExecuteCommandList(_CommandList); if (waitForCompletion) { CommandListManager.WaitForFence(fenceValue); } // Reset the command list and restore previous state _CommandList.Reset(_CurrentAllocator, null); if (_CurrentGraphicsRootSignature != null) { _CommandList.SetGraphicsRootSignature(_CurrentGraphicsRootSignature); _CommandList.PipelineState = _CurrentGraphicsPipelineState; } if (_CurrentComputeRootSignature != null) { _CommandList.SetComputeRootSignature(_CurrentComputeRootSignature); _CommandList.PipelineState = _CurrentComputePipelineState; } BindDescriptorHeaps(); return(fenceValue); }