From a292f8f017b7ddff3b07528b6f27cdca9f5cf820 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 16 Nov 2020 21:35:27 +0100 Subject: [PATCH] Added TerraFX PipelineData type --- .../Commands/CommandList2.cs | 6 +- .../Commands/PipelineData.cs | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/ComputeSharp.Graphics/Commands/PipelineData.cs diff --git a/src/ComputeSharp.Graphics/Commands/CommandList2.cs b/src/ComputeSharp.Graphics/Commands/CommandList2.cs index 2bdbed00..9fe49507 100644 --- a/src/ComputeSharp.Graphics/Commands/CommandList2.cs +++ b/src/ComputeSharp.Graphics/Commands/CommandList2.cs @@ -85,10 +85,10 @@ namespace ComputeSharp.Graphics.Commands /// Sets a given object ready to be executed. /// /// The input to setup. - public void SetPipelineState(PipelineState pipelineState) + public void SetPipelineData(PipelineData pipelineData) { - // TODO: D3D12GraphicsCommandList->SetComputeRootSignature() - // TODO: D3D12GraphicsCommandList->SetPipelineState() + D3D12GraphicsCommandList->SetComputeRootSignature(pipelineData.D3D12RootSignature); + D3D12GraphicsCommandList->SetPipelineState(pipelineData.D3D12PipelineState); } /// diff --git a/src/ComputeSharp.Graphics/Commands/PipelineData.cs b/src/ComputeSharp.Graphics/Commands/PipelineData.cs new file mode 100644 index 00000000..a63f677c --- /dev/null +++ b/src/ComputeSharp.Graphics/Commands/PipelineData.cs @@ -0,0 +1,56 @@ +using ComputeSharp.Core.Interop; +using TerraFX.Interop; + +namespace ComputeSharp.Graphics.Commands +{ + /// + /// A representing a custom pipeline state for a compute operation. + /// + internal sealed unsafe class PipelineData : NativeObject + { + /// + /// The instance for the current object. + /// + private ComPtr d3D12RootSignature; + + /// + /// The instance for the current object. + /// + private ComPtr d3D12PipelineState; + + /// + /// Creates a new instance with the specified parameters + /// + /// The to use + /// The value for the current shader + /// The bytecode for the compute shader to run + public PipelineData(ComPtr d3D12RootSignature, ComPtr d3D12PipelineState) + { + this.d3D12RootSignature = d3D12RootSignature; + this.d3D12PipelineState = d3D12PipelineState; + } + + /// + /// Gets the instance for the current object. + /// + public ID3D12RootSignature* D3D12RootSignature + { + get => this.d3D12RootSignature; + } + + /// + /// Gets the instance for the current object. + /// + public ID3D12PipelineState* D3D12PipelineState + { + get => this.d3D12PipelineState; + } + + /// + protected override void Dispose(bool disposing) + { + this.d3D12RootSignature.Dispose(); + this.d3D12PipelineState.Dispose(); + } + } +}