Minor code refactoring
このコミットが含まれているのは:
1 親
f14772b5d0
コミット
c263489b24
3ファイル変更
+49
-24
検索条件に一致するファイルはありません
@@ -2,6 +2,7 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -75,7 +76,7 @@ namespace ComputeSharp
|
||||
/// <summary>
|
||||
/// The <see cref="Allocator"/> in use associated to the current device.
|
||||
/// </summary>
|
||||
internal Allocator* allocator;
|
||||
internal AllocatorPtr allocator;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="ID3D12Device"/>.
|
||||
@@ -114,7 +115,7 @@ namespace ComputeSharp
|
||||
allocatorDesc.pDevice = d3D12Device;
|
||||
allocatorDesc.pAdapter = dxgiAdapter;
|
||||
|
||||
fixed (Allocator** allocator = &this.allocator)
|
||||
fixed (Allocator** allocator = this.allocator)
|
||||
{
|
||||
D3D12MemoryAllocator.CreateAllocator(&allocatorDesc, allocator).Assert();
|
||||
}
|
||||
@@ -161,6 +162,11 @@ namespace ComputeSharp
|
||||
/// </summary>
|
||||
internal ID3D12Device* D3D12Device => this.d3D12Device;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the underlying <see cref="Allocator"/> wrapped by the current instance.
|
||||
/// </summary>
|
||||
internal Allocator* Allocator => this.allocator;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current device has a cache coherent UMA architecture.
|
||||
/// </summary>
|
||||
@@ -331,12 +337,7 @@ namespace ComputeSharp
|
||||
this.computeCommandAllocatorPool.Dispose();
|
||||
this.copyCommandAllocatorPool.Dispose();
|
||||
this.shaderResourceViewDescriptorAllocator.Dispose();
|
||||
|
||||
if (this.allocator != null)
|
||||
{
|
||||
this.allocator->Release();
|
||||
this.allocator = null;
|
||||
}
|
||||
this.allocator.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp.Graphics.Interop
|
||||
namespace ComputeSharp.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="ComPtr{T}"/>-equivalent type to safely work with <see cref="Allocation"/> pointers.
|
||||
@@ -28,6 +29,16 @@ namespace ComputeSharp.Graphics.Interop
|
||||
pointer = other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unwraps a <see cref="AllocationPtr"/> instance and returns the internal raw pointer.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="AllocationPtr"/> instance to unwrap.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator Allocation*(AllocationPtr other)
|
||||
{
|
||||
return other.Get();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
@@ -66,16 +77,17 @@ namespace ComputeSharp.Graphics.Interop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the current <see cref="AllocationPtr"/> instance as a raw <see langword="void"/> double pointer.
|
||||
/// Gets the address of the current <see cref="AllocationPtr"/> instance as a managed <see cref="Allocation"/> reference to pointer.
|
||||
/// </summary>
|
||||
/// <returns>The raw pointer to the input <see cref="AllocationPtr"/> instance.</returns>
|
||||
/// <remarks>This method is only valid when the current <see cref="AllocationPtr"/> instance is on the stack or pinned.</remarks>
|
||||
[Pure]
|
||||
/// <returns>The reference to the current <see cref="AllocationPtr"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void** GetVoidAddressOf<T>()
|
||||
where T : unmanaged
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public readonly ref Allocation* GetPinnableReference()
|
||||
{
|
||||
return (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in this));
|
||||
fixed (Allocation** ptr = &this.pointer)
|
||||
{
|
||||
return ref *ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp.Graphics.Interop
|
||||
namespace ComputeSharp.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="ComPtr{T}"/>-equivalent type to safely work with <see cref="Allocator"/> pointers.
|
||||
@@ -28,6 +29,16 @@ namespace ComputeSharp.Graphics.Interop
|
||||
pointer = other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unwraps a <see cref="AllocatorPtr"/> instance and returns the internal raw pointer.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="AllocatorPtr"/> instance to unwrap.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator Allocator*(AllocatorPtr other)
|
||||
{
|
||||
return other.Get();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
@@ -66,16 +77,17 @@ namespace ComputeSharp.Graphics.Interop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the current <see cref="AllocatorPtr"/> instance as a raw <see langword="void"/> double pointer.
|
||||
/// Gets the address of the current <see cref="AllocatorPtr"/> instance as a managed <see cref="Allocator"/> reference to pointer.
|
||||
/// </summary>
|
||||
/// <returns>The raw pointer to the input <see cref="AllocatorPtr"/> instance.</returns>
|
||||
/// <remarks>This method is only valid when the current <see cref="AllocatorPtr"/> instance is on the stack or pinned.</remarks>
|
||||
[Pure]
|
||||
/// <returns>The reference to the current <see cref="AllocatorPtr"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void** GetVoidAddressOf<T>()
|
||||
where T : unmanaged
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public readonly ref Allocator* GetPinnableReference()
|
||||
{
|
||||
return (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in this));
|
||||
fixed (Allocator** ptr = &this.pointer)
|
||||
{
|
||||
return ref *ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする