diff --git a/ComputeSharp.sln b/ComputeSharp.sln
index 19c244ce..24463506 100644
--- a/ComputeSharp.sln
+++ b/ComputeSharp.sln
@@ -43,8 +43,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Tests.NativeLi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.SwapChain", "samples\ComputeSharp.SwapChain\ComputeSharp.SwapChain.csproj", "{E7C9247D-016B-4819-AF9F-0E9B3591E04B}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TerraFX.Interop.D3D12MemoryAllocator", "..\terrafx.interop.d3d12memoryallocator\sources\Interop\D3D12MemoryAllocator\TerraFX.Interop.D3D12MemoryAllocator.csproj", "{DB64E751-125D-44E2-8EA9-F5B085714007}"
-EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{7048deea-0a6f-46a0-b951-b682a8f1cb75}*SharedItemsImports = 5
@@ -154,14 +152,6 @@ Global
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|Any CPU.Build.0 = Release|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|x64.ActiveCfg = Release|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|x64.Build.0 = Release|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Debug|x64.ActiveCfg = Debug|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Debug|x64.Build.0 = Debug|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Release|Any CPU.Build.0 = Release|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Release|x64.ActiveCfg = Release|Any CPU
- {DB64E751-125D-44E2-8EA9-F5B085714007}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/ComputeSharp/ComputeSharp.csproj b/src/ComputeSharp/ComputeSharp.csproj
index eb294ea0..2119803e 100644
--- a/src/ComputeSharp/ComputeSharp.csproj
+++ b/src/ComputeSharp/ComputeSharp.csproj
@@ -10,10 +10,7 @@
-
-
-
-
+
diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs
index 76f1847f..1e77beb6 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/AllocatorExtensions.cs
@@ -5,31 +5,31 @@ using TerraFX.Interop;
using static TerraFX.Interop.D3D12_HEAP_TYPE;
using static TerraFX.Interop.D3D12_RESOURCE_FLAGS;
using static TerraFX.Interop.D3D12_RESOURCE_STATES;
-using static TerraFX.Interop.ALLOCATION_FLAGS;
+using static TerraFX.Interop.D3D12MA_ALLOCATION_FLAGS;
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
namespace ComputeSharp.Graphics.Extensions
{
///
- /// A with extensions for the type.
+ /// A with extensions for the type.
///
internal static unsafe class AllocatorExtensions
{
///
/// Creates a resource for a given buffer type.
///
- /// The instance in use.
+ /// The instance in use.
/// The resource type currently in use.
/// The allocation mode to use for the new resource.
/// The size in bytes of the current buffer.
- /// An reference for the current object.
- public static UniquePtr CreateResource(
- this ref Allocator allocator,
+ /// An reference for the current object.
+ public static UniquePtr CreateResource(
+ this ref D3D12MA_Allocator allocator,
ResourceType resourceType,
AllocationMode allocationMode,
ulong sizeInBytes)
{
- ALLOCATION_FLAGS allocationFlags = allocationMode == AllocationMode.Default ? ALLOCATION_FLAG_NONE : ALLOCATION_FLAG_COMMITTED;
+ D3D12MA_ALLOCATION_FLAGS allocationFlags = allocationMode == AllocationMode.Default ? D3D12MA_ALLOCATION_FLAG_NONE : D3D12MA_ALLOCATION_FLAG_COMMITTED;
(D3D12_HEAP_TYPE d3D12HeapType,
D3D12_RESOURCE_FLAGS d3D12ResourceFlags,
D3D12_RESOURCE_STATES d3D12ResourceStates) = resourceType switch
@@ -42,11 +42,11 @@ namespace ComputeSharp.Graphics.Extensions
_ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
};
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Buffer(sizeInBytes, d3D12ResourceFlags);
- ALLOCATION_DESC allocationDesc = default;
+ D3D12MA_ALLOCATION_DESC allocationDesc = default;
allocationDesc.HeapType = d3D12HeapType;
allocationDesc.Flags = allocationFlags;
@@ -65,16 +65,16 @@ namespace ComputeSharp.Graphics.Extensions
///
/// Creates a resource for a given 2D texture type.
///
- /// The instance in use.
+ /// The instance in use.
/// The resource type currently in use.
/// The allocation mode to use for the new resource.
/// The value to use.
/// The width of the texture resource.
/// The height of the texture resource.
/// The default value for the resource.
- /// An reference for the current object.
- public static UniquePtr CreateResource(
- this ref Allocator allocator,
+ /// An reference for the current object.
+ public static UniquePtr CreateResource(
+ this ref D3D12MA_Allocator allocator,
ResourceType resourceType,
AllocationMode allocationMode,
DXGI_FORMAT dxgiFormat,
@@ -82,7 +82,7 @@ namespace ComputeSharp.Graphics.Extensions
uint height,
out D3D12_RESOURCE_STATES d3D12ResourceStates)
{
- ALLOCATION_FLAGS allocationFlags = allocationMode == AllocationMode.Default ? ALLOCATION_FLAG_NONE : ALLOCATION_FLAG_COMMITTED;
+ D3D12MA_ALLOCATION_FLAGS allocationFlags = allocationMode == AllocationMode.Default ? D3D12MA_ALLOCATION_FLAG_NONE : D3D12MA_ALLOCATION_FLAG_COMMITTED;
D3D12_RESOURCE_FLAGS d3D12ResourceFlags;
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
@@ -92,11 +92,11 @@ namespace ComputeSharp.Graphics.Extensions
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
};
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(dxgiFormat, width, height, mipLevels: 1, flags: d3D12ResourceFlags);
- ALLOCATION_DESC allocationDesc = default;
+ D3D12MA_ALLOCATION_DESC allocationDesc = default;
allocationDesc.HeapType = D3D12_HEAP_TYPE_DEFAULT;
allocationDesc.Flags = allocationFlags;
@@ -115,7 +115,7 @@ namespace ComputeSharp.Graphics.Extensions
///
/// Creates a resource for a given 3D texture type.
///
- /// The instance in use.
+ /// The instance in use.
/// The resource type currently in use.
/// The allocation mode to use for the new resource.
/// The value to use.
@@ -123,9 +123,9 @@ namespace ComputeSharp.Graphics.Extensions
/// The height of the texture resource.
/// The depth of the texture resource.
/// The default value for the resource.
- /// An reference for the current object.
- public static UniquePtr CreateResource(
- this ref Allocator allocator,
+ /// An reference for the current object.
+ public static UniquePtr CreateResource(
+ this ref D3D12MA_Allocator allocator,
ResourceType resourceType,
AllocationMode allocationMode,
DXGI_FORMAT dxgiFormat,
@@ -134,7 +134,7 @@ namespace ComputeSharp.Graphics.Extensions
ushort depth,
out D3D12_RESOURCE_STATES d3D12ResourceStates)
{
- ALLOCATION_FLAGS allocationFlags = allocationMode == AllocationMode.Default ? ALLOCATION_FLAG_NONE : ALLOCATION_FLAG_COMMITTED;
+ D3D12MA_ALLOCATION_FLAGS allocationFlags = allocationMode == AllocationMode.Default ? D3D12MA_ALLOCATION_FLAG_NONE : D3D12MA_ALLOCATION_FLAG_COMMITTED;
D3D12_RESOURCE_FLAGS d3D12ResourceFlags;
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
@@ -144,11 +144,11 @@ namespace ComputeSharp.Graphics.Extensions
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
};
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(dxgiFormat, width, height, depth, mipLevels: 1, flags: d3D12ResourceFlags);
- ALLOCATION_DESC allocationDesc = default;
+ D3D12MA_ALLOCATION_DESC allocationDesc = default;
allocationDesc.HeapType = D3D12_HEAP_TYPE_DEFAULT;
allocationDesc.Flags = allocationFlags;
diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.cs
index d4f2a75e..affde884 100644
--- a/src/ComputeSharp/Graphics/GraphicsDevice.cs
+++ b/src/ComputeSharp/Graphics/GraphicsDevice.cs
@@ -73,9 +73,9 @@ namespace ComputeSharp
private ulong nextD3D12CopyFenceValue = 1;
///
- /// The in use associated to the current device.
+ /// The in use associated to the current device.
///
- private UniquePtr allocator;
+ private UniquePtr allocator;
///
/// Creates a new instance for the input .
@@ -110,15 +110,15 @@ namespace ComputeSharp
IsCacheCoherentUMA = d3D12Architecture1Data.CacheCoherentUMA != 0;
- ALLOCATOR_DESC allocatorDesc = default;
+ D3D12MA_ALLOCATOR_DESC allocatorDesc = default;
allocatorDesc.pDevice = d3D12Device;
allocatorDesc.pAdapter = dxgiAdapter;
if (!IsCacheCoherentUMA)
{
- fixed (Allocator** allocator = this.allocator)
+ fixed (D3D12MA_Allocator** allocator = this.allocator)
{
- D3D12MemoryAllocator.CreateAllocator(&allocatorDesc, allocator).Assert();
+ D3D12MemAlloc.D3D12MA_CreateAllocator(&allocatorDesc, allocator).Assert();
}
}
}
@@ -165,9 +165,9 @@ namespace ComputeSharp
internal ID3D12Device* D3D12Device => this.d3D12Device;
///
- /// Gets the underlying wrapped by the current instance.
+ /// Gets the underlying wrapped by the current instance.
///
- internal Allocator* Allocator => this.allocator;
+ internal D3D12MA_Allocator* Allocator => this.allocator;
///
/// Gets whether or not the current device has a cache coherent UMA architecture.
diff --git a/src/ComputeSharp/Graphics/Interop/UniquePtr{T}.cs b/src/ComputeSharp/Graphics/Interop/UniquePtr{T}.cs
index 071d6f3b..2cec96e1 100644
--- a/src/ComputeSharp/Graphics/Interop/UniquePtr{T}.cs
+++ b/src/ComputeSharp/Graphics/Interop/UniquePtr{T}.cs
@@ -7,9 +7,9 @@ using TerraFX.Interop;
namespace ComputeSharp.Interop
{
///
- /// A -equivalent type to safely work with pointers to public APIs.
+ /// A -equivalent type to safely work with pointers to public APIs.
///
- /// Must be either , , or .
+ /// Must be either , , or .
///
/// This type is not marked as so that it can also be used in fields, so make sure to
/// avoid copying it and disposing it multiple times, as that would lead to a access violation exceptions.
@@ -51,10 +51,10 @@ namespace ComputeSharp.Interop
{
this.pointer = null;
- if (typeof(T) == typeof(Allocator)) ((Allocator*)pointer)->Release();
- else if (typeof(T) == typeof(Allocation)) ((Allocation*)pointer)->Release();
- else if (typeof(T) == typeof(Pool)) ((Pool*)pointer)->Release();
- else if (typeof(T) == typeof(VirtualBlock)) ((VirtualBlock*)pointer)->Release();
+ if (typeof(T) == typeof(D3D12MA_Allocator)) ((D3D12MA_Allocator*)pointer)->Release();
+ else if (typeof(T) == typeof(D3D12MA_Allocation)) ((D3D12MA_Allocation*)pointer)->Release();
+ else if (typeof(T) == typeof(D3D12MA_Pool)) ((D3D12MA_Pool*)pointer)->Release();
+ else if (typeof(T) == typeof(D3D12MA_VirtualBlock)) ((D3D12MA_VirtualBlock*)pointer)->Release();
else throw new ArgumentException("Invalid pointer type");
}
}
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
index e459ccc4..f1cca2ad 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
@@ -39,10 +39,10 @@ namespace ComputeSharp.Resources
protected readonly nint SizeInBytes;
///
- /// The instance used to retrieve , if any.
+ /// The instance used to retrieve , if any.
///
/// This will be if the owning device has set.
- private UniquePtr allocation;
+ private UniquePtr allocation;
///
/// Creates a new instance with the specified parameters.
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs
index 32f0630e..1266141d 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs
@@ -59,7 +59,7 @@ namespace ComputeSharp.Resources
byteOffset = (nint)offset * sizeof(T),
byteLength = length * sizeof(T);
- using UniquePtr allocation = GraphicsDevice.Allocator->CreateResource(ResourceType.ReadBack, AllocationMode.Default, (ulong)byteLength);
+ using UniquePtr allocation = GraphicsDevice.Allocator->CreateResource(ResourceType.ReadBack, AllocationMode.Default, (ulong)byteLength);
using (CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY))
{
@@ -157,7 +157,7 @@ namespace ComputeSharp.Resources
byteOffset = (nint)offset * sizeof(T),
byteLength = length * sizeof(T);
- using UniquePtr allocation = GraphicsDevice.Allocator->CreateResource(ResourceType.Upload, AllocationMode.Default, (ulong)byteLength);
+ using UniquePtr allocation = GraphicsDevice.Allocator->CreateResource(ResourceType.Upload, AllocationMode.Default, (ulong)byteLength);
using (ID3D12ResourceMap resource = allocation.Get()->GetResource()->Map())
fixed (void* sourcePointer = &source)
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs
index ead1d3e9..5cfdce19 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs
@@ -57,10 +57,10 @@ namespace ComputeSharp.Resources
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
///
- /// The instance used to retrieve , if any.
+ /// The instance used to retrieve , if any.
///
/// This will be if the owning device has set.
- private UniquePtr allocation;
+ private UniquePtr allocation;
///
/// Creates a new instance with the specified parameters.
@@ -105,6 +105,7 @@ namespace ComputeSharp.Resources
(uint)width,
(uint)height,
out this.d3D12ResourceState);
+
this.d3D12Resource = new ComPtr(this.allocation.Get()->GetResource());
}
@@ -186,7 +187,7 @@ namespace ComputeSharp.Resources
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
using ComPtr d3D12Resource = default;
if (GraphicsDevice.IsCacheCoherentUMA)
@@ -336,7 +337,7 @@ namespace ComputeSharp.Resources
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
using ComPtr d3D12Resource = default;
if (GraphicsDevice.IsCacheCoherentUMA)
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs
index 7fb6b115..f29c2db8 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs
@@ -57,10 +57,10 @@ namespace ComputeSharp.Resources
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
///
- /// The instance used to retrieve , if any.
+ /// The instance used to retrieve , if any.
///
/// This will be if the owning device has set.
- private UniquePtr allocation;
+ private UniquePtr allocation;
///
/// Creates a new instance with the specified parameters.
@@ -109,6 +109,7 @@ namespace ComputeSharp.Resources
(uint)height,
(ushort)depth,
out this.d3D12ResourceState);
+
this.d3D12Resource = new ComPtr(this.allocation.Get()->GetResource());
}
@@ -202,7 +203,7 @@ namespace ComputeSharp.Resources
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
using ComPtr d3D12Resource = default;
if (GraphicsDevice.IsCacheCoherentUMA)
@@ -369,7 +370,7 @@ namespace ComputeSharp.Resources
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
- using UniquePtr allocation = default;
+ using UniquePtr allocation = default;
using ComPtr d3D12Resource = default;
if (GraphicsDevice.IsCacheCoherentUMA)
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs
index f4489052..66887f0c 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs
@@ -28,10 +28,10 @@ namespace ComputeSharp.Resources
private readonly T* mappedData;
///
- /// The instance used to retrieve , if any.
+ /// The instance used to retrieve , if any.
///
/// This will be if the owning device has set.
- private UniquePtr allocation;
+ private UniquePtr allocation;
///
/// Creates a new instance with the specified parameters.
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs
index 8a2a8292..4a5e2d61 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs
@@ -34,10 +34,10 @@ namespace ComputeSharp.Resources
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
///
- /// The instance used to retrieve , if any.
+ /// The instance used to retrieve , if any.
///
/// This will be if the owning device has set.
- private UniquePtr allocation;
+ private UniquePtr allocation;
///
/// Creates a new instance with the specified parameters.
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs
index ce51f3e8..42e4b092 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs
@@ -34,10 +34,10 @@ namespace ComputeSharp.Resources
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
///
- /// The instance used to retrieve , if any.
+ /// The instance used to retrieve , if any.
///
/// This will be if the owning device has set.
- private UniquePtr allocation;
+ private UniquePtr allocation;
///
/// Creates a new instance with the specified parameters.