Ejemplo n.º 1
0
        public void UsageAfterDispose(Device device, Type bufferType)
        {
            using TransferBuffer <float> buffer = device.Get().AllocateTransferBuffer <float>(bufferType, 128);

            buffer.Dispose();

            _ = buffer.Span;
        }
    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();
    }