Enabled copy command list for readonly textures
このコミットが含まれているのは:
1 親
5fafd3d9ac
コミット
03bbbe7724
5ファイル変更
+66
-20
検索条件に一致するファイルはありません
@@ -36,7 +36,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <summary>
|
||||
/// The default <see cref="D3D12_RESOURCE_STATES"/> value for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_RESOURCE_STATES D3D12ResourceState;
|
||||
private readonly D3D12_RESOURCE_STATES d3D12ResourceState;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_COMMAND_LIST_TYPE"/> value to use for copy operations.
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Texture2D{T}"/> instance with the specified parameters.
|
||||
@@ -61,7 +66,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
out D3D12ResourceState);
|
||||
out this.d3D12ResourceState);
|
||||
|
||||
this.d3D12CommandListType = this.d3D12ResourceState == D3D12_RESOURCE_STATE_COMMON
|
||||
? D3D12_COMMAND_LIST_TYPE_COPY
|
||||
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
|
||||
|
||||
device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
|
||||
|
||||
@@ -130,9 +139,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, totalSizeInBytes);
|
||||
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COMPUTE))
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType))
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
}
|
||||
|
||||
copyCommandList.CopyTextureRegion(
|
||||
d3D12Resource.Get(),
|
||||
@@ -145,7 +157,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
(uint)height,
|
||||
1);
|
||||
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12ResourceState);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
|
||||
}
|
||||
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
@@ -207,9 +223,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch);
|
||||
}
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COMPUTE);
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
}
|
||||
|
||||
copyCommandList.CopyTextureRegion(
|
||||
D3D12Resource,
|
||||
@@ -219,7 +238,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprint);
|
||||
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, D3D12ResourceState);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
|
||||
}
|
||||
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <summary>
|
||||
/// The default <see cref="D3D12_RESOURCE_STATES"/> value for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_RESOURCE_STATES D3D12ResourceState;
|
||||
private readonly D3D12_RESOURCE_STATES d3D12ResourceState;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_COMMAND_LIST_TYPE"/> value to use for copy operations.
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Texture3D{T}"/> instance with the specified parameters.
|
||||
@@ -65,7 +70,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out D3D12ResourceState);
|
||||
out this.d3D12ResourceState);
|
||||
|
||||
this.d3D12CommandListType = this.d3D12ResourceState == D3D12_RESOURCE_STATE_COMMON
|
||||
? D3D12_COMMAND_LIST_TYPE_COPY
|
||||
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
|
||||
|
||||
device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
|
||||
|
||||
@@ -144,9 +153,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, totalSizeInBytes);
|
||||
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COMPUTE))
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType))
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
}
|
||||
|
||||
copyCommandList.CopyTextureRegion(
|
||||
d3D12Resource.Get(),
|
||||
@@ -159,7 +171,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
(uint)height,
|
||||
(ushort)depth);
|
||||
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12ResourceState);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
|
||||
}
|
||||
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
@@ -230,9 +246,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch * (uint)height);
|
||||
}
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COMPUTE);
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
}
|
||||
|
||||
copyCommandList.CopyTextureRegion(
|
||||
D3D12Resource,
|
||||
@@ -242,7 +261,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprint);
|
||||
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, D3D12ResourceState);
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
|
||||
}
|
||||
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace ComputeSharp.Graphics.Commands
|
||||
/// <summary>
|
||||
/// Gets the command list type being used by the current instance.
|
||||
/// </summary>
|
||||
public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3D12CommandListType;
|
||||
public readonly D3D12_COMMAND_LIST_TYPE D3D12CommandListType => this.d3D12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// Detaches the <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
|
||||
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
};
|
||||
@@ -214,7 +214,7 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
|
||||
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
};
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace ComputeSharp.Graphics
|
||||
ulong d3D12FenceValue;
|
||||
|
||||
// Get the target command queue, fence and pool for the list type
|
||||
switch (commandList.D3d12CommandListType)
|
||||
switch (commandList.D3D12CommandListType)
|
||||
{
|
||||
case D3D12_COMMAND_LIST_TYPE_COMPUTE:
|
||||
commandAllocatorPool = ref this.computeCommandAllocatorPool;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする