Move GPU disposal tests to DeviceLost test project
このコミットが含まれているのは:
1 親
2623754991
コミット
37823f366c
9ファイル変更
+47
-167
検索条件に一致するファイルはありません
@@ -86,6 +86,10 @@ public partial class DeviceDisposalTests
|
||||
using var r3 = graphicsDevice.AllocateReadWriteBuffer<float>(128);
|
||||
using var r4 = graphicsDevice.AllocateReadOnlyTexture2D<float>(128, 128);
|
||||
using var r5 = graphicsDevice.AllocateReadWriteTexture2D<float>(128, 128);
|
||||
using var r6 = graphicsDevice.AllocateUploadBuffer<float>(128);
|
||||
using var r7 = graphicsDevice.AllocateReadBackBuffer<float>(128);
|
||||
using var r8 = graphicsDevice.AllocateUploadTexture2D<float>(128, 128);
|
||||
using var r9 = graphicsDevice.AllocateReadBackTexture2D<float>(128, 128);
|
||||
|
||||
InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device.GetAddressOf());
|
||||
}
|
||||
|
||||
@@ -73,4 +73,47 @@ public class GetDefaultDeviceTests
|
||||
|
||||
GetDefault_VerifyContract_Part2();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public unsafe void GetDefault_DisposeAndUseNewInstance()
|
||||
{
|
||||
using (ComPtr<ID3D12Device> d3D12Device = default)
|
||||
{
|
||||
GraphicsDevice device = GraphicsDevice.GetDefault();
|
||||
|
||||
using (device.AllocateReadOnlyBuffer<float>(128))
|
||||
{
|
||||
}
|
||||
|
||||
InteropServices.GetID3D12Device(device, Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device.GetAddressOf());
|
||||
|
||||
device.Dispose();
|
||||
|
||||
_ = d3D12Device.Get()->AddRef();
|
||||
|
||||
uint refCount = d3D12Device.Get()->Release();
|
||||
|
||||
Assert.AreEqual(refCount, 1u);
|
||||
}
|
||||
|
||||
// Just same test but twice, just for good measure
|
||||
using (ComPtr<ID3D12Device> d3D12Device = default)
|
||||
{
|
||||
GraphicsDevice device = GraphicsDevice.GetDefault();
|
||||
|
||||
using (device.AllocateReadOnlyBuffer<float>(128))
|
||||
{
|
||||
}
|
||||
|
||||
InteropServices.GetID3D12Device(device, Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device.GetAddressOf());
|
||||
|
||||
device.Dispose();
|
||||
|
||||
_ = d3D12Device.Get()->AddRef();
|
||||
|
||||
uint refCount = d3D12Device.Get()->Release();
|
||||
|
||||
Assert.AreEqual(refCount, 1u);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,33 +124,6 @@ public partial class BufferTests
|
||||
_ = 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 => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => GraphicsDevice.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<>))]
|
||||
|
||||
@@ -28,16 +28,6 @@ public partial class InitializationTests
|
||||
Assert.IsTrue(gpu.WavefrontSize != 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DisposeDefault()
|
||||
{
|
||||
using var before = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer<float>(128);
|
||||
|
||||
GraphicsDevice.GetDefault().Dispose();
|
||||
|
||||
using var after = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer<float>(128);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnumerateDevices()
|
||||
{
|
||||
|
||||
@@ -86,32 +86,6 @@ public partial class Texture2DTests
|
||||
_ = texture.ToArray();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture2D<>))]
|
||||
[Resource(typeof(ReadWriteTexture2D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => GraphicsDevice.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,32 +105,6 @@ public partial class Texture3DTests
|
||||
_ = texture.ToArray();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture3D<>))]
|
||||
[Resource(typeof(ReadWriteTexture3D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => GraphicsDevice.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,32 +66,6 @@ public partial class TransferBufferTests
|
||||
_ = buffer.Span;
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(UploadBuffer<>))]
|
||||
[Resource(typeof(ReadBackBuffer<>))]
|
||||
public void DisposeAfterDevice(Device device, Type bufferType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => GraphicsDevice.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_CopyTo_Full(Device device)
|
||||
|
||||
@@ -70,32 +70,6 @@ public partial class TransferTexture2DTests
|
||||
_ = texture.View;
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(UploadTexture2D<>))]
|
||||
[Resource(typeof(ReadBackTexture2D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => GraphicsDevice.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 unsafe void Allocate_UploadTexture2D_Copy_Full(Device device)
|
||||
|
||||
@@ -77,32 +77,6 @@ public partial class TransferTexture3DTests
|
||||
_ = texture.View;
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(UploadTexture3D<>))]
|
||||
[Resource(typeof(ReadBackTexture3D<>))]
|
||||
public void DisposeAfterDevice(Device device, Type textureType)
|
||||
{
|
||||
GraphicsDevice? gpu = device switch
|
||||
{
|
||||
Device.Discrete => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => GraphicsDevice.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 unsafe void Allocate_UploadTexture3D_Copy_Full(Device device)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする