Code refactoring to TransferTexture2D<T>

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-03 19:30:21 +01:00
1 親 a4ded10a10
コミット 5223615824
2ファイル変更
+44 -98

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

+1 -55
ファイルの表示
@@ -1,6 +1,4 @@
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Graphics.Helpers;
@@ -123,57 +121,5 @@ namespace ComputeSharp.Resources
GraphicsDeviceMismatchException.Throw(this, device);
}
}
/// <summary>
/// A <see cref="MemoryManager{T}"/> implementation wrapping a <see cref="TransferTexture2D{T}"/> instance.
/// </summary>
private sealed class MemoryManager : MemoryManager<T>
{
/// <summary>
/// The <see cref="TransferTexture2D{T}"/> in use.
/// </summary>
private readonly TransferTexture2D<T> texture;
/// <summary>
/// Creates a new <see cref="MemoryManager"/> instance for a given texture.
/// </summary>
/// <param name="texture">The <see cref="TransferTexture2D{T}"/> in use.</param>
public MemoryManager(TransferTexture2D<T> texture)
{
this.texture = texture;
}
/// <inheritdoc/>
public override Memory<T> Memory
{
get => ThrowHelper.ThrowNotSupportedException<Memory<T>>();
}
/// <inheritdoc/>
public override Span<T> GetSpan()
{
return new(this.texture.mappedData, this.texture.Width * (this.texture.Width + this.texture.rowPitch));
}
/// <inheritdoc/>
public override MemoryHandle Pin(int elementIndex = 0)
{
Guard.IsEqualTo(elementIndex, 0, nameof(elementIndex));
this.texture.ThrowIfDisposed();
return new(this.texture.mappedData);
}
/// <inheritdoc/>
public override void Unpin()
{
}
/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
}
}
}
}