Removed Vortice.Windows references and files
このコミットが含まれているのは:
1 親
b67af4aaa1
コミット
4811769ebc
46ファイル変更
+1124
-3358
検索条件に一致するファイルはありません
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using Vortice.Direct3D12;
|
||||
|
||||
namespace ComputeSharp.Graphics.Commands.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// A base <see langword="class"/> for an instance that deals with GPU commands in some way
|
||||
/// </summary>
|
||||
internal abstract class CommandController : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CommandAllocatorPool"/> instance with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="device">The input <see cref="Graphics.GraphicsDevice"/> to use to perform requested operations</param>
|
||||
/// <param name="commandListType">The type of command list to use for the current instance</param>
|
||||
protected CommandController(GraphicsDevice device, CommandListType commandListType)
|
||||
{
|
||||
GraphicsDevice = device;
|
||||
CommandListType = commandListType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Graphics.GraphicsDevice"/> object targeted by the current instance
|
||||
/// </summary>
|
||||
public GraphicsDevice GraphicsDevice { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the command list type being used by the current instance
|
||||
/// </summary>
|
||||
public CommandListType CommandListType { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Graphics.Commands.Abstract;
|
||||
using SharpGen.Runtime;
|
||||
using Vortice.Direct3D12;
|
||||
|
||||
namespace ComputeSharp.Graphics.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that acts as a pool to get new <see cref="ID3D12CommandAllocator"/> instances wheen needed
|
||||
/// </summary>
|
||||
internal sealed class CommandAllocatorPool : CommandController
|
||||
{
|
||||
/// <summary>
|
||||
/// The queue of currently pooled <see cref="ID3D12CommandAllocator"/> instances
|
||||
/// </summary>
|
||||
private readonly Queue<(ID3D12CommandAllocator CommandAllocator, long FenceValue)> CommandAllocatorQueue = new Queue<(ID3D12CommandAllocator, long)>();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public CommandAllocatorPool(GraphicsDevice device, CommandListType commandListType) : base(device, commandListType) { }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new <see cref="ID3D12CommandAllocator"/> item to the internal pool queue
|
||||
/// </summary>
|
||||
/// <param name="commandAllocator">The input <see cref="ID3D12CommandAllocator"/> to enqueue</param>
|
||||
/// <param name="fenceValue">The fence value for the input <see cref="ID3D12CommandAllocator"/></param>
|
||||
public void Enqueue(ID3D12CommandAllocator commandAllocator, long fenceValue)
|
||||
{
|
||||
lock (CommandAllocatorQueue)
|
||||
{
|
||||
CommandAllocatorQueue.Enqueue((commandAllocator, fenceValue));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a new or reused <see cref="ID3D12CommandAllocator"/> item to use to issue GPU commands
|
||||
/// </summary>
|
||||
[Pure]
|
||||
public ID3D12CommandAllocator GetCommandAllocator()
|
||||
{
|
||||
lock (CommandAllocatorQueue)
|
||||
{
|
||||
// Reuse an existing command allocator, if one is present in the queue
|
||||
if (CommandAllocatorQueue.Count > 0)
|
||||
{
|
||||
(ID3D12CommandAllocator commandAllocator, long fenceValue) = CommandAllocatorQueue.Peek();
|
||||
|
||||
long completedValue = CommandListType switch
|
||||
{
|
||||
CommandListType.Compute => GraphicsDevice.NativeComputeFence.CompletedValue,
|
||||
CommandListType.Copy => GraphicsDevice.NativeCopyFence.CompletedValue,
|
||||
_ => throw new NotSupportedException($"Unsupported command list type with value {CommandListType}")
|
||||
};
|
||||
|
||||
if (fenceValue <= completedValue)
|
||||
{
|
||||
CommandAllocatorQueue.Dequeue();
|
||||
commandAllocator.Reset();
|
||||
|
||||
return commandAllocator;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new command allocator
|
||||
Result result = GraphicsDevice.NativeDevice.CreateCommandAllocator(CommandListType, out ID3D12CommandAllocator? nativeCommandAllocator);
|
||||
|
||||
if (result.Failure)
|
||||
{
|
||||
throw new COMException("Failed to create the command allocator", result.Code);
|
||||
}
|
||||
|
||||
return nativeCommandAllocator!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (CommandAllocatorQueue)
|
||||
{
|
||||
foreach ((ID3D12CommandAllocator commandAllocator, long _) in CommandAllocatorQueue)
|
||||
{
|
||||
commandAllocator.Dispose();
|
||||
}
|
||||
|
||||
CommandAllocatorQueue.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +1,142 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Exceptions;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
using ComputeSharp.Graphics.Commands.Abstract;
|
||||
using SharpGen.Runtime;
|
||||
using Vortice.Direct3D12;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using TerraFX.Interop;
|
||||
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
|
||||
|
||||
namespace ComputeSharp.Graphics.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that represents a list of commands to issue to a GPU
|
||||
/// A command list to set and execute operaations on the GPU.
|
||||
/// </summary>
|
||||
internal sealed class CommandList : CommandController
|
||||
internal unsafe ref struct CommandList
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public CommandList(GraphicsDevice device, CommandListType commandListType) : base(device, commandListType)
|
||||
/// <summary>
|
||||
/// The <see cref="GraphicsDevice"/> instance associated with the current command list.
|
||||
/// </summary>
|
||||
private readonly GraphicsDevice device;
|
||||
|
||||
/// <summary>
|
||||
/// The command list type being used by the current instance.
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3d12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12GraphicsCommandList"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12GraphicsCommandList> d3D12GraphicsCommandList;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CommandList"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to use.</param>
|
||||
/// <param name="d3d12CommandListType">The type of command list to create.</param>
|
||||
public CommandList(GraphicsDevice device, D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
|
||||
{
|
||||
CommandAllocator = CommandListType switch
|
||||
{
|
||||
CommandListType.Compute => GraphicsDevice.ComputeAllocatorPool.GetCommandAllocator(),
|
||||
CommandListType.Copy => GraphicsDevice.CopyAllocatorPool.GetCommandAllocator(),
|
||||
_ => throw new NotSupportedException($"Unsupported command list type with value {CommandListType}")
|
||||
};
|
||||
|
||||
Result result = GraphicsDevice.NativeDevice.CreateCommandList(0, commandListType, CommandAllocator, null, out ID3D12GraphicsCommandList? nativeCommandList);
|
||||
|
||||
if (result.Failure)
|
||||
{
|
||||
throw new COMException("Failed to create the commands list", result.Code);
|
||||
}
|
||||
|
||||
NativeCommandList = nativeCommandList!;
|
||||
this.device = device;
|
||||
this.d3d12CommandListType = d3d12CommandListType;
|
||||
this.d3D12CommandAllocator = device.GetCommandAllocator(d3d12CommandListType);
|
||||
this.d3D12GraphicsCommandList = device.D3D12Device->CreateCommandList(d3d12CommandListType, this.d3D12CommandAllocator);
|
||||
|
||||
// Set the heap descriptor if the command list is not for copy operations
|
||||
if (CommandListType != CommandListType.Copy)
|
||||
if (d3d12CommandListType is not D3D12_COMMAND_LIST_TYPE_COPY)
|
||||
{
|
||||
NativeCommandList.SetDescriptorHeaps(1, new[] { GraphicsDevice.ShaderResourceViewAllocator.DescriptorHeap });
|
||||
device.SetDescriptorHeapForCommandList(this.d3D12GraphicsCommandList);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the command list type being used by the current instance.
|
||||
/// </summary>
|
||||
public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3d12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ID3D12CommandAllocator"/> object in use by the current instance
|
||||
/// Detaches the <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
public ID3D12CommandAllocator CommandAllocator { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ID3D12GraphicsCommandList"/> object in use by the current instance
|
||||
/// </summary>
|
||||
public ID3D12GraphicsCommandList NativeCommandList { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Copies a memory region from one resource to another
|
||||
/// </summary>
|
||||
/// <param name="source">The source <see cref="GraphicsResource"/> to read from</param>
|
||||
/// <param name="sourceOffset">The starting offset to read the source resource from</param>
|
||||
/// <param name="destination">The destination <see cref="GraphicsResource"/> to write to</param>
|
||||
/// <param name="destinationOffset">The starting offset to write the destination resource from</param>
|
||||
/// <param name="numBytes">The total number of bytes to copy from one resource to another</param>
|
||||
public void CopyBufferRegion(GraphicsResource source, long sourceOffset, GraphicsResource destination, long destinationOffset, long numBytes)
|
||||
/// <returns>The <see cref="ID3D12CommandAllocator"/> object in use, with ownership.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ComPtr<ID3D12CommandAllocator> DetachD3D12CommandAllocator()
|
||||
{
|
||||
NativeCommandList.CopyBufferRegion(destination.NativeResource, destinationOffset, source.NativeResource, sourceOffset, numBytes);
|
||||
return this.d3D12CommandAllocator.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Binds an input <see cref="GraphicsResource"/> object to a specified root parameter
|
||||
/// Gets a pointer to the <see cref="ID3D12CommandList"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
/// <param name="rootParameterIndex">The root parameter index to bind to the input resource</param>
|
||||
/// <param name="resource">The input <see cref="GraphicsResource"/> instance to bind</param>
|
||||
public void SetComputeRootDescriptorTable(int rootParameterIndex, GraphicsResource resource)
|
||||
/// <returns>A double pointer to the current <see cref="ID3D12CommandList"/> object to execute.</returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ID3D12CommandList** GetD3D12CommandListAddressOf()
|
||||
{
|
||||
if (resource.NativeGpuDescriptorHandle == null) throw new InvalidOperationException("Invalid graphics resource GPU descriptor");
|
||||
if (resource.GraphicsDevice != GraphicsDevice) throw new GraphicsDeviceMismatchException(GraphicsDevice, resource);
|
||||
|
||||
NativeCommandList.SetComputeRootDescriptorTable(rootParameterIndex, resource.NativeGpuDescriptorHandle.Value);
|
||||
return this.d3D12GraphicsCommandList.Upcast<ID3D12GraphicsCommandList, ID3D12CommandList>().GetAddressOf();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a given <see cref="PipelineState"/> object ready to be executed
|
||||
/// Copies a memory region from one resource to another.
|
||||
/// </summary>
|
||||
/// <param name="pipelineState">The input <see cref="PipelineState"/> to setup</param>
|
||||
public void SetPipelineState(PipelineState pipelineState)
|
||||
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> to read from.</param>
|
||||
/// <param name="sourceOffset">The starting offset to read the source resource from.</param>
|
||||
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> to write to.</param>
|
||||
/// <param name="destinationOffset">The starting offset to write the destination resource from.</param>
|
||||
/// <param name="numBytes">The total number of bytes to copy from one resource to another.</param>
|
||||
public readonly void CopyBufferRegion(ID3D12Resource* d3D12ResourceSource, int sourceOffset, ID3D12Resource* d3d12ResourceDestination, int destinationOffset, int numBytes)
|
||||
{
|
||||
NativeCommandList.SetComputeRootSignature(pipelineState.RootSignature);
|
||||
NativeCommandList.SetPipelineState(pipelineState.NativePipelineState);
|
||||
this.d3D12GraphicsCommandList.Get()->CopyBufferRegion(d3d12ResourceDestination, (uint)destinationOffset, d3D12ResourceSource, (uint)sourceOffset, (uint)numBytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatches the pending shader using the specified thread group values
|
||||
/// Binds an input <see cref="GraphicsResource"/> object to a specified root parameter.
|
||||
/// </summary>
|
||||
/// <param name="threadGroupCountX">The number of thread groups to schedule for the X axis</param>
|
||||
/// <param name="threadGroupCountY">The number of thread groups to schedule for the Y axis</param>
|
||||
/// <param name="threadGroupCountZ">The number of thread groups to schedule for the Z axis</param>
|
||||
public void Dispatch(int threadGroupCountX, int threadGroupCountY, int threadGroupCountZ)
|
||||
/// <param name="rootParameterIndex">The root parameter index to bind to the input resource.</param>
|
||||
/// <param name="resource">The input <see cref="GraphicsResource"/> instance to bind.</param>
|
||||
public readonly void SetComputeRootDescriptorTable(int rootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
NativeCommandList.Dispatch(threadGroupCountX, threadGroupCountY, threadGroupCountZ);
|
||||
this.d3D12GraphicsCommandList.Get()->SetComputeRootDescriptorTable((uint)rootParameterIndex, d3D12GpuDescriptorHandle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the commands in the current commands list, and waits for completion
|
||||
/// Sets a given <see cref="PipelineData"/> object ready to be executed.
|
||||
/// </summary>
|
||||
/// <param name="pipelineState">The input <see cref="PipelineData"/> to setup.</param>
|
||||
public readonly void SetPipelineData(PipelineData pipelineData)
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->SetComputeRootSignature(pipelineData.D3D12RootSignature);
|
||||
this.d3D12GraphicsCommandList.Get()->SetPipelineState(pipelineData.D3D12PipelineState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatches the pending shader using the specified thread group values.
|
||||
/// </summary>
|
||||
/// <param name="threadGroupCountX">The number of thread groups to schedule for the X axis.</param>
|
||||
/// <param name="threadGroupCountY">The number of thread groups to schedule for the Y axis.</param>
|
||||
/// <param name="threadGroupCountZ">The number of thread groups to schedule for the Z axis.</param>
|
||||
public readonly void Dispatch(int threadGroupCountX, int threadGroupCountY, int threadGroupCountZ)
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->Dispatch((uint)threadGroupCountX, (uint)threadGroupCountY, (uint)threadGroupCountZ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the commands in the current commands list, and waits for completion.
|
||||
/// </summary>
|
||||
public void ExecuteAndWaitForCompletion()
|
||||
{
|
||||
NativeCommandList.Close();
|
||||
this.d3D12GraphicsCommandList.Get()->Close();
|
||||
|
||||
GraphicsDevice.ExecuteCommandList(this);
|
||||
this.device.ExecuteCommandList(ref this);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Dispose()
|
||||
/// <inheritdoc cref="IDisposable.Dispose"/>
|
||||
public void Dispose()
|
||||
{
|
||||
NativeCommandList.Dispose();
|
||||
this.d3D12CommandAllocator.Dispose();
|
||||
this.d3D12GraphicsCommandList.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using TerraFX.Interop;
|
||||
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
|
||||
|
||||
namespace ComputeSharp.Graphics.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A command list to set and execute operaations on the GPU.
|
||||
/// </summary>
|
||||
internal unsafe ref struct CommandList2
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="GraphicsDevice2"/> instance associated with the current command list.
|
||||
/// </summary>
|
||||
private readonly GraphicsDevice2 device;
|
||||
|
||||
/// <summary>
|
||||
/// The command list type being used by the current instance.
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3d12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12GraphicsCommandList"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12GraphicsCommandList> d3D12GraphicsCommandList;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CommandList2"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice2"/> instance to use.</param>
|
||||
/// <param name="d3d12CommandListType">The type of command list to create.</param>
|
||||
public CommandList2(GraphicsDevice2 device, D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
|
||||
{
|
||||
this.device = device;
|
||||
this.d3d12CommandListType = d3d12CommandListType;
|
||||
this.d3D12CommandAllocator = device.GetCommandAllocator(d3d12CommandListType);
|
||||
this.d3D12GraphicsCommandList = device.D3D12Device->CreateCommandList(d3d12CommandListType, this.d3D12CommandAllocator);
|
||||
|
||||
// Set the heap descriptor if the command list is not for copy operations
|
||||
if (d3d12CommandListType is not D3D12_COMMAND_LIST_TYPE_COPY)
|
||||
{
|
||||
device.SetDescriptorHeapForCommandList(this.d3D12GraphicsCommandList);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the command list type being used by the current instance.
|
||||
/// </summary>
|
||||
public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3d12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// Detaches the <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="ID3D12CommandAllocator"/> object in use, with ownership.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ComPtr<ID3D12CommandAllocator> DetachD3D12CommandAllocator()
|
||||
{
|
||||
return this.d3D12CommandAllocator.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pointer to the <see cref="ID3D12CommandList"/> object in use by the current instance.
|
||||
/// </summary>
|
||||
/// <returns>A double pointer to the current <see cref="ID3D12CommandList"/> object to execute.</returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ID3D12CommandList** GetD3D12CommandListAddressOf()
|
||||
{
|
||||
return this.d3D12GraphicsCommandList.Upcast<ID3D12GraphicsCommandList, ID3D12CommandList>().GetAddressOf();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies a memory region from one resource to another.
|
||||
/// </summary>
|
||||
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> to read from.</param>
|
||||
/// <param name="sourceOffset">The starting offset to read the source resource from.</param>
|
||||
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> to write to.</param>
|
||||
/// <param name="destinationOffset">The starting offset to write the destination resource from.</param>
|
||||
/// <param name="numBytes">The total number of bytes to copy from one resource to another.</param>
|
||||
public readonly void CopyBufferRegion(ID3D12Resource* d3D12ResourceSource, int sourceOffset, ID3D12Resource* d3d12ResourceDestination, int destinationOffset, int numBytes)
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->CopyBufferRegion(d3d12ResourceDestination, (uint)destinationOffset, d3D12ResourceSource, (uint)sourceOffset, (uint)numBytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Binds an input <see cref="GraphicsResource"/> object to a specified root parameter.
|
||||
/// </summary>
|
||||
/// <param name="rootParameterIndex">The root parameter index to bind to the input resource.</param>
|
||||
/// <param name="resource">The input <see cref="GraphicsResource"/> instance to bind.</param>
|
||||
public readonly void SetComputeRootDescriptorTable(int rootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->SetComputeRootDescriptorTable((uint)rootParameterIndex, d3D12GpuDescriptorHandle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a given <see cref="PipelineData"/> object ready to be executed.
|
||||
/// </summary>
|
||||
/// <param name="pipelineState">The input <see cref="PipelineData"/> to setup.</param>
|
||||
public readonly void SetPipelineData(PipelineData pipelineData)
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->SetComputeRootSignature(pipelineData.D3D12RootSignature);
|
||||
this.d3D12GraphicsCommandList.Get()->SetPipelineState(pipelineData.D3D12PipelineState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatches the pending shader using the specified thread group values.
|
||||
/// </summary>
|
||||
/// <param name="threadGroupCountX">The number of thread groups to schedule for the X axis.</param>
|
||||
/// <param name="threadGroupCountY">The number of thread groups to schedule for the Y axis.</param>
|
||||
/// <param name="threadGroupCountZ">The number of thread groups to schedule for the Z axis.</param>
|
||||
public readonly void Dispatch(int threadGroupCountX, int threadGroupCountY, int threadGroupCountZ)
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->Dispatch((uint)threadGroupCountX, (uint)threadGroupCountY, (uint)threadGroupCountZ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the commands in the current commands list, and waits for completion.
|
||||
/// </summary>
|
||||
public void ExecuteAndWaitForCompletion()
|
||||
{
|
||||
this.d3D12GraphicsCommandList.Get()->Close();
|
||||
|
||||
this.device.ExecuteCommandList(ref this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IDisposable.Dispose"/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.d3D12CommandAllocator.Dispose();
|
||||
this.d3D12GraphicsCommandList.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using Vortice.Direct3D12;
|
||||
|
||||
namespace ComputeSharp.Graphics.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a custom pipeline state for a compute operation
|
||||
/// </summary>
|
||||
internal sealed class PipelineState : ComputePipelineStateDescription
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PipelineState"/> instance with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> to use</param>
|
||||
/// <param name="rootSignature">The <see cref="ID3D12RootSignature"/> value for the current shader</param>
|
||||
/// <param name="computeShader">The bytecode for the compute shader to run</param>
|
||||
public PipelineState(GraphicsDevice device, ID3D12RootSignature rootSignature, ShaderBytecode computeShader)
|
||||
{
|
||||
RootSignature = rootSignature;
|
||||
ComputeShader = computeShader;
|
||||
|
||||
NativePipelineState = device.NativeDevice.CreateComputePipelineState<ID3D12PipelineState>(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ID3D12PipelineState"/> instance for the current <see cref="PipelineState"/> object
|
||||
/// </summary>
|
||||
public ID3D12PipelineState NativePipelineState { get; }
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする