public void Close()
        {
            NativeCommandList.Close();

            // Recycle heaps
            ResetSrvHeap(false);
            ResetSamplerHeap(false);

            var fenceValue = GraphicsDevice.ExecuteCommandListInternal(NativeCommandList);

            GraphicsDevice.CommandAllocators.RecycleObject(fenceValue, nativeCommandAllocator);
            nativeCommandAllocator = null;
        }
        private void FlushInternal(bool wait)
        {
            var fenceValue = GraphicsDevice.ExecuteCommandListInternal(Close());

            if (wait)
            {
                GraphicsDevice.WaitForFenceInternal(fenceValue);
            }

            Reset();

            // Restore states
            if (boundPipelineState != null)
            {
                SetPipelineState(boundPipelineState);
            }
            currentCommandList.NativeCommandList.SetDescriptorHeaps(2, descriptorHeaps);
            SetRenderTargetsImpl(depthStencilBuffer, renderTargetCount, renderTargets);
        }
        private long FlushInternal(bool wait)
        {
            NativeCommandList.Close();

            var fenceValue = GraphicsDevice.ExecuteCommandListInternal(NativeCommandList);

            if (wait)
            {
                GraphicsDevice.WaitForFenceInternal(fenceValue);
            }

            NativeCommandList.Reset(nativeCommandAllocator, null);

            // Restore states
            if (boundPipelineState != null)
            {
                SetPipelineState(boundPipelineState);
            }
            NativeCommandList.SetDescriptorHeaps(2, descriptorHeaps);
            SetRenderTargetsImpl(depthStencilBuffer, renderTargetCount, renderTargets);

            return(fenceValue);
        }