public void ResourceBarrier(uint NumBarriers, [NativeTypeName("const D3D12_RESOURCE_BARRIER *")] D3D12_RESOURCE_BARRIER *pBarriers)
 {
     ((delegate * unmanaged <ID3D12VideoDecodeCommandList2 *, uint, D3D12_RESOURCE_BARRIER *, void>)(lpVtbl[12]))((ID3D12VideoDecodeCommandList2 *)Unsafe.AsPointer(ref this), NumBarriers, pBarriers);
 }
Пример #2
0
 public void ResourceBarrier([NativeTypeName("UINT")] uint NumBarriers, [NativeTypeName("const D3D12_RESOURCE_BARRIER *")] D3D12_RESOURCE_BARRIER *pBarriers)
 {
     ((delegate * unmanaged <ID3D12GraphicsCommandList1 *, uint, D3D12_RESOURCE_BARRIER *, void>)(lpVtbl[26]))((ID3D12GraphicsCommandList1 *)Unsafe.AsPointer(ref this), NumBarriers, pBarriers);
 }
Пример #3
0
 public void ResourceBarrier([NativeTypeName("UINT")] uint NumBarriers, [NativeTypeName("const D3D12_RESOURCE_BARRIER *")] D3D12_RESOURCE_BARRIER *pBarriers)
 {
     ((delegate * stdcall <ID3D12VideoProcessCommandList *, uint, D3D12_RESOURCE_BARRIER *, void>)(lpVtbl[12]))((ID3D12VideoProcessCommandList *)Unsafe.AsPointer(ref this), NumBarriers, pBarriers);
 }
    /// <inheritdoc/>
    public override unsafe void OnUpdate(TimeSpan time)
    {
        if (this.isResizePending)
        {
            ApplyResize();

            this.isResizePending = false;
        }

        // Generate the new frame
        GraphicsDevice.Default.ForEach(this.texture !, this.shaderFactory(time));

        using ComPtr <ID3D12Resource> d3D12Resource = default;

        // Get the underlying ID3D12Resource pointer for the texture
        _ = InteropServices.TryGetID3D12Resource(this.texture !, Windows.__uuidof <ID3D12Resource>(), (void **)d3D12Resource.GetAddressOf());

        // Get the target back buffer to update
        ID3D12Resource *d3D12ResourceBackBuffer = this.currentBufferIndex switch
        {
            0 => this.d3D12Resource0.Get(),
            1 => this.d3D12Resource1.Get(),
            _ => null
        };

        this.currentBufferIndex ^= 1;

        // Reset the command list and command allocator
        this.d3D12CommandAllocator.Get()->Reset();
        this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null);

        D3D12_RESOURCE_BARRIER *d3D12ResourceBarriers = stackalloc D3D12_RESOURCE_BARRIER[]
        {
            D3D12_RESOURCE_BARRIER.InitTransition(
                d3D12Resource.Get(),
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_SOURCE),
            D3D12_RESOURCE_BARRIER.InitTransition(
                d3D12ResourceBackBuffer,
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON,
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_DEST)
        };

        // Transition the resources to COPY_DEST and COPY_SOURCE respectively
        d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);

        // Copy the generated frame to the target back buffer
        d3D12GraphicsCommandList.Get()->CopyResource(d3D12ResourceBackBuffer, d3D12Resource.Get());

        d3D12ResourceBarriers[0] = D3D12_RESOURCE_BARRIER.InitTransition(
            d3D12Resource.Get(),
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_SOURCE,
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_UNORDERED_ACCESS);

        d3D12ResourceBarriers[1] = D3D12_RESOURCE_BARRIER.InitTransition(
            d3D12ResourceBackBuffer,
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_DEST,
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON);

        // Transition the resources back to COMMON and UNORDERED_ACCESS respectively
        d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);

        d3D12GraphicsCommandList.Get()->Close();

        // Execute the command list to perform the copy
        this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList **)d3D12GraphicsCommandList.GetAddressOf());
        this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);

        // Present the new frame
        this.dxgiSwapChain1.Get()->Present(0, 0);

        if (this.nextD3D12FenceValue > this.d3D12Fence.Get()->GetCompletedValue())
        {
            this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
        }

        this.nextD3D12FenceValue++;
    }
}