Added D3D12MA support to transfer resource types

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-05 17:40:12 +01:00
1 親 ed952e0fdb
コミット e0350ccb0c
5ファイル変更
+58 -7

検索条件に一致するファイルはありません

+18 -2
ファイルの表示
@@ -33,6 +33,12 @@ namespace ComputeSharp.Resources
/// </summary>
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
/// <summary>
/// The <see cref="Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>, if any.
/// </summary>
/// <remarks>This will be <see langword="null"/> if the owning device has <see cref="GraphicsDevice.IsCacheCoherentUMA"/> set.</remarks>
private UniquePtr<Allocation> allocation;
/// <summary>
/// Creates a new <see cref="TransferTexture3D{T}"/> instance with the specified parameters.
/// </summary>
@@ -57,7 +63,7 @@ namespace ComputeSharp.Resources
GraphicsDevice = device;
GraphicsDevice.D3D12Device->GetCopyableFootprint(
device.D3D12Device->GetCopyableFootprint(
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
@@ -66,7 +72,16 @@ namespace ComputeSharp.Resources
out _,
out ulong totalSizeInBytes);
this.d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA);
if (device.IsCacheCoherentUMA)
{
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, true);
}
else
{
this.allocation = device.Allocator->CreateResource(resourceType, allocationMode, totalSizeInBytes);
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
}
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
this.d3D12Resource.Get()->SetName(this);
@@ -117,6 +132,7 @@ namespace ComputeSharp.Resources
protected override bool OnDispose()
{
this.d3D12Resource.Dispose();
this.allocation.Dispose();
return true;
}