Exemplo n.º 1
0
 public void Dispose()
 {
     mFenceValue++;
     mpCmdQueue.Signal(mpFence, mFenceValue);
     mpFence.SetEventOnCompletion(mFenceValue, mFenceEvent);
     mFenceEvent.WaitOne();
 }
Exemplo n.º 2
0
 private void SubmitCommandList()
 {
     commandList.Close();
     commandQueue.ExecuteCommandList(commandList);
     fenceValue++;
     commandQueue.Signal(fence, fenceValue);
 }
Exemplo n.º 3
0
 public uint SubmitCommandList(ID3D12GraphicsCommandList4 pCmdList, ID3D12CommandQueue pCmdQueue, ID3D12Fence pFence, uint fenceValue)
 {
     pCmdList.Close();
     pCmdQueue.ExecuteCommandList(pCmdList);
     fenceValue++;
     pCmdQueue.Signal(pFence, fenceValue);
     return(fenceValue);
 }
Exemplo n.º 4
0
    public void CloseExecuteResetWait()
    {
        D3D12CommandList.Close();

        D3D12CommandQueue.ExecuteCommandList(D3D12CommandList);

        using var fence = D3D12Device.CreateFence();
        var waitHandle = new AutoResetEvent(false);

        fence.SetEventOnCompletion(1, waitHandle);

        D3D12CommandQueue.Signal(fence, 1);

        waitHandle.WaitOne();

        D3D12CommandAllocator.Reset();
        D3D12CommandList.Reset(D3D12CommandAllocator);
    }
Exemplo n.º 5
0
        /// <inheritdoc/>
        public void Dispose()
        {
            NativeDirectCommandQueue.Signal(NativeDirectFence, NextDirectFenceValue);
            NativeDirectCommandQueue.Wait(NativeDirectFence, NextDirectFenceValue);

            ShaderResourceViewAllocator.Dispose();

            ComputeAllocatorPool.Dispose();
            CopyAllocatorPool.Dispose();
            DirectAllocatorPool.Dispose();

            NativeComputeCommandQueue.Dispose();
            NativeCopyCommandQueue.Dispose();
            NativeDirectCommandQueue.Dispose();

            NativeComputeFence.Dispose();
            NativeDirectFence.Dispose();
            NativeDirectFence.Dispose();

            NativeDevice.Dispose();
        }
Exemplo n.º 6
0
        private void WaitForPreviousFrame()
        {
            // WAITING FOR THE FRAME TO COMPLETE BEFORE CONTINUING IS NOT BEST PRACTICE.
            // This is code implemented as such for simplicity. The D3D12HelloFrameBuffering
            // sample illustrates how to use fences for efficient resource usage and to
            // maximize GPU utilization.

            // Signal and increment the fence value.
            var fenceValueToSignal = _fenceValue;

            _d3d12CommandQueue.Signal(_d3d12Fence, fenceValueToSignal);
            _fenceValue++;

            // Wait until the previous frame is finished.
            if (_d3d12Fence.CompletedValue < fenceValueToSignal)
            {
                _d3d12Fence.SetEventOnCompletion(fenceValueToSignal, _fenceEvent);
                _fenceEvent.WaitOne();
            }

            _frameIndex = SwapChain3.GetCurrentBackBufferIndex();
        }
Exemplo n.º 7
0
 public void Signal(ID3D12CommandQueue queue, ulong fenceValue)
 {
     queue.Signal(_fence, fenceValue);
 }