保留コマンドリスト上限をAppContextで構成可能化
このコミットが含まれているのは:
1 親
f02ef49753
コミット
b2cf968fd8
2ファイル変更
+19
-8
検索条件に一致するファイルはありません
@@ -12,16 +12,15 @@ namespace ComputeSharp.Graphics.Commands.Interop;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="d3D12CommandListType">The command list type to use.</param>
|
/// <param name="d3D12CommandListType">The command list type to use.</param>
|
||||||
/// <param name="d3D12Fence">The fence used to track deferred command list completion.</param>
|
/// <param name="d3D12Fence">The fence used to track deferred command list completion.</param>
|
||||||
internal readonly unsafe struct ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE d3D12CommandListType, ID3D12Fence* d3D12Fence) : IDisposable
|
/// <param name="maximumPendingCommandListCount">保留可能なコマンドリスト数の上限。</param>
|
||||||
|
internal readonly unsafe struct ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE d3D12CommandListType, ID3D12Fence* d3D12Fence, int maximumPendingCommandListCount) : IDisposable
|
||||||
{
|
{
|
||||||
private const int MaximumPendingCommandListCount = 16;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The queue of <see cref="D3D12CommandListBundle"/> items with the available command lists.
|
/// The queue of <see cref="D3D12CommandListBundle"/> items with the available command lists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Queue<D3D12CommandListBundle> d3D12CommandListBundleQueue = new(MaximumPendingCommandListCount * 2);
|
private readonly Queue<D3D12CommandListBundle> d3D12CommandListBundleQueue = new(maximumPendingCommandListCount * 2);
|
||||||
|
|
||||||
private readonly Queue<PendingD3D12CommandListBundle> pendingD3D12CommandListBundleQueue = new(MaximumPendingCommandListCount);
|
private readonly Queue<PendingD3D12CommandListBundle> pendingD3D12CommandListBundleQueue = new(maximumPendingCommandListCount);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rents a <see cref="ID3D12GraphicsCommandList"/> and <see cref="ID3D12CommandAllocator"/> pair.
|
/// Rents a <see cref="ID3D12GraphicsCommandList"/> and <see cref="ID3D12CommandAllocator"/> pair.
|
||||||
@@ -84,7 +83,7 @@ internal readonly unsafe struct ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE d3
|
|||||||
{
|
{
|
||||||
ReclaimCompletedCommandLists();
|
ReclaimCompletedCommandLists();
|
||||||
|
|
||||||
if (this.pendingD3D12CommandListBundleQueue.Count == MaximumPendingCommandListCount)
|
if (this.pendingD3D12CommandListBundleQueue.Count >= maximumPendingCommandListCount)
|
||||||
{
|
{
|
||||||
pendingD3D12CommandListBundle = this.pendingD3D12CommandListBundleQueue.Dequeue();
|
pendingD3D12CommandListBundle = this.pendingD3D12CommandListBundleQueue.Dequeue();
|
||||||
hasPendingD3D12CommandListBundle = true;
|
hasPendingD3D12CommandListBundle = true;
|
||||||
|
|||||||
@@ -153,9 +153,11 @@ public sealed unsafe partial class GraphicsDevice : IReferenceTrackedObject
|
|||||||
this.d3D12CopyCommandQueue = d3D12Device->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COPY);
|
this.d3D12CopyCommandQueue = d3D12Device->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COPY);
|
||||||
this.d3D12ComputeFence = d3D12Device->CreateFence();
|
this.d3D12ComputeFence = d3D12Device->CreateFence();
|
||||||
this.d3D12CopyFence = d3D12Device->CreateFence();
|
this.d3D12CopyFence = d3D12Device->CreateFence();
|
||||||
|
int maximumPendingCommandListCount = GetMaximumPendingCommandListCount();
|
||||||
|
|
||||||
this.shaderResourceViewDescriptorAllocator = new ID3D12DescriptorHandleAllocator(d3D12Device);
|
this.shaderResourceViewDescriptorAllocator = new ID3D12DescriptorHandleAllocator(d3D12Device);
|
||||||
this.computeCommandListPool = new ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE_COMPUTE, this.d3D12ComputeFence.Get());
|
this.computeCommandListPool = new ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE_COMPUTE, this.d3D12ComputeFence.Get(), maximumPendingCommandListCount);
|
||||||
this.copyCommandListPool = new ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE_COPY, this.d3D12CopyFence.Get());
|
this.copyCommandListPool = new ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE_COPY, this.d3D12CopyFence.Get(), maximumPendingCommandListCount);
|
||||||
this.allocator = new ComPtr<ID3D12MemoryAllocator>(allocator);
|
this.allocator = new ComPtr<ID3D12MemoryAllocator>(allocator);
|
||||||
|
|
||||||
Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid);
|
Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid);
|
||||||
@@ -342,6 +344,16 @@ public sealed unsafe partial class GraphicsDevice : IReferenceTrackedObject
|
|||||||
D3D12_FORMAT_SUPPORT1_TEXTURE3D | D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW);
|
D3D12_FORMAT_SUPPORT1_TEXTURE3D | D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int GetMaximumPendingCommandListCount()
|
||||||
|
{
|
||||||
|
return AppContext.GetData("ComputeSharp.MaximumPendingCommandListCount") switch
|
||||||
|
{
|
||||||
|
int count when count > 0 => count,
|
||||||
|
string text when int.TryParse(text, out int count) && count > 0 => count,
|
||||||
|
_ => 16
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a <see cref="PipelineData"/> object for the current device to enable early disposal.
|
/// Registers a <see cref="PipelineData"/> object for the current device to enable early disposal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
新しいイシューから参照
ユーザーをブロックする