Added D3D12MA support to transfer resource types

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

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

+1 -1
ファイルの表示
@@ -113,7 +113,7 @@ namespace ComputeSharp.Resources
? D3D12_COMMAND_LIST_TYPE_COPY
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
GraphicsDevice.D3D12Device->GetCopyableFootprint(
device.D3D12Device->GetCopyableFootprint(
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
+2 -1
ファイルの表示
@@ -117,7 +117,7 @@ namespace ComputeSharp.Resources
? D3D12_COMMAND_LIST_TYPE_COPY
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
GraphicsDevice.D3D12Device->GetCopyableFootprint(
device.D3D12Device->GetCopyableFootprint(
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
@@ -502,6 +502,7 @@ namespace ComputeSharp.Resources
protected override bool OnDispose()
{
this.d3D12Resource.Dispose();
this.allocation.Dispose();
if (GraphicsDevice?.IsDisposed == false)
{
+18 -1
ファイルの表示
@@ -2,6 +2,7 @@
using System.Buffers;
using System.Runtime.CompilerServices;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Interop;
using Microsoft.Toolkit.Diagnostics;
@@ -27,6 +28,12 @@ namespace ComputeSharp.Resources
/// </summary>
private readonly T* mappedData;
/// <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="TransferBuffer{T}"/> instance with the specified parameters.
/// </summary>
@@ -46,7 +53,16 @@ namespace ComputeSharp.Resources
ulong sizeInBytes = (uint)length * (uint)sizeof(T);
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, sizeInBytes, device.IsCacheCoherentUMA);
if (device.IsCacheCoherentUMA)
{
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, sizeInBytes, true);
}
else
{
this.allocation = device.Allocator->CreateResource(resourceType, allocationMode, sizeInBytes);
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
}
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
this.d3D12Resource.Get()->SetName(this);
@@ -100,6 +116,7 @@ namespace ComputeSharp.Resources
protected override bool OnDispose()
{
this.d3D12Resource.Dispose();
this.allocation.Dispose();
return true;
}
+19 -2
ファイルの表示
@@ -1,5 +1,6 @@
using System.Runtime.CompilerServices;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Graphics.Helpers;
using ComputeSharp.Interop;
@@ -33,6 +34,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="TransferTexture2D{T}"/> instance with the specified parameters.
/// </summary>
@@ -55,7 +62,7 @@ namespace ComputeSharp.Resources
GraphicsDevice = device;
GraphicsDevice.D3D12Device->GetCopyableFootprint(
device.D3D12Device->GetCopyableFootprint(
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
@@ -63,7 +70,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);
@@ -110,6 +126,7 @@ namespace ComputeSharp.Resources
protected override bool OnDispose()
{
this.d3D12Resource.Dispose();
this.allocation.Dispose();
return true;
}
+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;
}