Fixed resource disposing after owning device
このコミットが含まれているのは:
1 親
c7f7eac265
コミット
df970a5e40
12ファイル変更
+190
-12
検索条件に一致するファイルはありません
@@ -111,6 +111,33 @@ namespace ComputeSharp.Tests
|
||||
_ = buffer.ToArray();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ConstantBuffer<>))]
|
||||
[Resource(typeof(ReadOnlyBuffer<>))]
|
||||
[Resource(typeof(ReadWriteBuffer<>))]
|
||||
public void DisposeAfterDevice(Device device, Type bufferType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => throw new ArgumentException(nameof(device))
|
||||
};
|
||||
|
||||
if (gpu is null)
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Buffer<float> buffer = gpu.AllocateBuffer<float>(bufferType, 128);
|
||||
|
||||
gpu.Dispose();
|
||||
buffer.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ConstantBuffer<>))]
|
||||
|
||||
@@ -86,6 +86,32 @@ namespace ComputeSharp.Tests
|
||||
_ = texture.ToArray();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture2D<>))]
|
||||
[Resource(typeof(ReadWriteTexture2D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => throw new ArgumentException(nameof(device))
|
||||
};
|
||||
|
||||
if (gpu is null)
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Texture2D<float> texture = gpu.AllocateTexture2D<float>(textureType, 10, 10);
|
||||
|
||||
gpu.Dispose();
|
||||
texture.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture2D<>))]
|
||||
|
||||
@@ -105,6 +105,32 @@ namespace ComputeSharp.Tests
|
||||
_ = texture.ToArray();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture3D<>))]
|
||||
[Resource(typeof(ReadWriteTexture3D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => throw new ArgumentException(nameof(device))
|
||||
};
|
||||
|
||||
if (gpu is null)
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Texture3D<float> texture = gpu.AllocateTexture3D<float>(textureType, 10, 10, 4);
|
||||
|
||||
gpu.Dispose();
|
||||
texture.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture3D<>))]
|
||||
|
||||
@@ -66,6 +66,32 @@ namespace ComputeSharp.Tests
|
||||
_ = buffer.Span;
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(UploadBuffer<>))]
|
||||
[Resource(typeof(ReadBackBuffer<>))]
|
||||
public void DisposeAfterDevice(Device device, Type bufferType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => throw new ArgumentException(nameof(device))
|
||||
};
|
||||
|
||||
if (gpu is null)
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TransferBuffer<float> buffer = gpu.AllocateTransferBuffer<float>(bufferType, 128);
|
||||
|
||||
gpu.Dispose();
|
||||
buffer.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_UploadBuffer_Copy_Full(Device device)
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace ComputeSharp.Tests
|
||||
[Resource(typeof(ReadBackTexture2D<>))]
|
||||
[Data(AllocationMode.Default)]
|
||||
[Data(AllocationMode.Clear)]
|
||||
public unsafe void Allocate_Uninitialized_Ok(Device device, Type bufferType, AllocationMode allocationMode)
|
||||
public unsafe void Allocate_Uninitialized_Ok(Device device, Type textureType, AllocationMode allocationMode)
|
||||
{
|
||||
using TransferTexture2D<float> texture = device.Get().AllocateTransferTexture2D<float>(bufferType, 128, 256, allocationMode);
|
||||
using TransferTexture2D<float> texture = device.Get().AllocateTransferTexture2D<float>(textureType, 128, 256, allocationMode);
|
||||
|
||||
Assert.IsNotNull(texture);
|
||||
Assert.AreEqual(texture.Width, 128);
|
||||
@@ -50,9 +50,9 @@ namespace ComputeSharp.Tests
|
||||
[Data(0, -4314)]
|
||||
[Data(-14, -53)]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void Allocate_Uninitialized_Fail(Device device, Type bufferType, int width, int height)
|
||||
public void Allocate_Uninitialized_Fail(Device device, Type textureType, int width, int height)
|
||||
{
|
||||
using TransferTexture2D<float> texture = device.Get().AllocateTransferTexture2D<float>(bufferType, width, height);
|
||||
using TransferTexture2D<float> texture = device.Get().AllocateTransferTexture2D<float>(textureType, width, height);
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
@@ -60,15 +60,41 @@ namespace ComputeSharp.Tests
|
||||
[Resource(typeof(UploadTexture2D<>))]
|
||||
[Resource(typeof(ReadBackTexture2D<>))]
|
||||
[ExpectedException(typeof(ObjectDisposedException))]
|
||||
public void UsageAfterDispose(Device device, Type bufferType)
|
||||
public void UsageAfterDispose(Device device, Type textureType)
|
||||
{
|
||||
using TransferTexture2D<float> texture = device.Get().AllocateTransferTexture2D<float>(bufferType, 32, 32);
|
||||
using TransferTexture2D<float> texture = device.Get().AllocateTransferTexture2D<float>(textureType, 32, 32);
|
||||
|
||||
texture.Dispose();
|
||||
|
||||
_ = texture.View;
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(UploadTexture2D<>))]
|
||||
[Resource(typeof(ReadBackTexture2D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => throw new ArgumentException(nameof(device))
|
||||
};
|
||||
|
||||
if (gpu is null)
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TransferTexture2D<float> texture = gpu.AllocateTransferTexture2D<float>(textureType, 32, 32);
|
||||
|
||||
gpu.Dispose();
|
||||
texture.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_UploadTexture2D_Copy_Full(Device device)
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace ComputeSharp.Tests
|
||||
[Resource(typeof(ReadBackTexture3D<>))]
|
||||
[Data(AllocationMode.Default)]
|
||||
[Data(AllocationMode.Clear)]
|
||||
public unsafe void Allocate_Uninitialized_Ok(Device device, Type bufferType, AllocationMode allocationMode)
|
||||
public unsafe void Allocate_Uninitialized_Ok(Device device, Type textureType, AllocationMode allocationMode)
|
||||
{
|
||||
using TransferTexture3D<float> texture = device.Get().AllocateTransferTexture3D<float>(bufferType, 128, 256, 32, allocationMode);
|
||||
using TransferTexture3D<float> texture = device.Get().AllocateTransferTexture3D<float>(textureType, 128, 256, 32, allocationMode);
|
||||
|
||||
Assert.IsNotNull(texture);
|
||||
Assert.AreEqual(texture.Width, 128);
|
||||
@@ -57,9 +57,9 @@ namespace ComputeSharp.Tests
|
||||
[Data(12, 12, -1)]
|
||||
[Data(2, 4, ushort.MaxValue + 1)]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void Allocate_Uninitialized_Fail(Device device, Type bufferType, int width, int height, int depth)
|
||||
public void Allocate_Uninitialized_Fail(Device device, Type textureType, int width, int height, int depth)
|
||||
{
|
||||
using TransferTexture3D<float> texture = device.Get().AllocateTransferTexture3D<float>(bufferType, width, height, depth);
|
||||
using TransferTexture3D<float> texture = device.Get().AllocateTransferTexture3D<float>(textureType, width, height, depth);
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
@@ -67,15 +67,41 @@ namespace ComputeSharp.Tests
|
||||
[Resource(typeof(UploadTexture3D<>))]
|
||||
[Resource(typeof(ReadBackTexture3D<>))]
|
||||
[ExpectedException(typeof(ObjectDisposedException))]
|
||||
public void UsageAfterDispose(Device device, Type bufferType)
|
||||
public void UsageAfterDispose(Device device, Type textureType)
|
||||
{
|
||||
using TransferTexture3D<float> texture = device.Get().AllocateTransferTexture3D<float>(bufferType, 32, 32, 16);
|
||||
using TransferTexture3D<float> texture = device.Get().AllocateTransferTexture3D<float>(textureType, 32, 32, 16);
|
||||
|
||||
texture.Dispose();
|
||||
|
||||
_ = texture.View;
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(UploadTexture3D<>))]
|
||||
[Resource(typeof(ReadBackTexture3D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => throw new ArgumentException(nameof(device))
|
||||
};
|
||||
|
||||
if (gpu is null)
|
||||
{
|
||||
Assert.Inconclusive();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TransferTexture3D<float> texture = gpu.AllocateTransferTexture3D<float>(textureType, 32, 32, 16);
|
||||
|
||||
gpu.Dispose();
|
||||
texture.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_UploadTexture3D_Copy_Full(Device device)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする