diff --git a/samples/ComputeSharp.Sample.SwapChain/Program.cs b/samples/ComputeSharp.Sample.SwapChain/Program.cs
index 97f112a9..b8e2c34e 100644
--- a/samples/ComputeSharp.Sample.SwapChain/Program.cs
+++ b/samples/ComputeSharp.Sample.SwapChain/Program.cs
@@ -1,7 +1,6 @@
using System;
using System.Drawing;
using ComputeSharp.Interop;
-using Microsoft.Toolkit.Diagnostics;
using TerraFX.Interop;
using FX = TerraFX.Interop.Windows;
@@ -70,7 +69,7 @@ namespace ComputeSharp.Sample.SwapChain
///
/// The instance used to prepare frames to display.
///
- private ReadWriteTexture2D texture = null!;
+ private ReadWriteTexture2D? texture;
public override string Title => "Fractal tiles";
@@ -176,6 +175,13 @@ namespace ComputeSharp.Sample.SwapChain
// Close the command list to prepare it for future use
this.d3D12GraphicsCommandList.Get()->Close();
+ }
+
+ public override unsafe void OnResize(Size size)
+ {
+ this.texture?.Dispose();
+
+ D3D12_RESOURCE_DESC d3D12Resource0Description = this.d3D12Resource0.Get()->GetDesc();
// Create the 2D texture to use to generate frames to display
this.texture = Gpu.Default.AllocateReadWriteTexture2D(
@@ -183,14 +189,10 @@ namespace ComputeSharp.Sample.SwapChain
(int)d3D12Resource0Description.Height);
}
- public override void OnResize(Size size)
- {
- }
-
public override unsafe void OnUpdate(TimeSpan time)
{
// Generate the new frame
- Gpu.Default.For(texture.Width, texture.Height, new FractalTiling(texture, (float)time.TotalSeconds));
+ Gpu.Default.For(texture!.Width, texture.Height, new FractalTiling(texture, (float)time.TotalSeconds));
using ComPtr d3D12Resource = default;
@@ -258,10 +260,6 @@ namespace ComputeSharp.Sample.SwapChain
// Present the new frame
this.dxgiSwapChain1.Get()->Present(0, 0);
}
-
- public override void Dispose()
- {
- }
}
[AutoConstructor]
diff --git a/samples/ComputeSharp.Sample.SwapChain/Win32ApplicationRunner.cs b/samples/ComputeSharp.Sample.SwapChain/Win32ApplicationRunner.cs
index a0ec1e0e..bfdbda7d 100644
--- a/samples/ComputeSharp.Sample.SwapChain/Win32ApplicationRunner.cs
+++ b/samples/ComputeSharp.Sample.SwapChain/Win32ApplicationRunner.cs
@@ -9,7 +9,7 @@ using FX = TerraFX.Interop.Windows;
namespace ComputeSharp.Sample.SwapChain
{
- internal abstract class Win32Application : IDisposable
+ internal abstract class Win32Application
{
public abstract string Title { get; }
@@ -18,8 +18,6 @@ namespace ComputeSharp.Sample.SwapChain
public abstract void OnResize(Size size);
public abstract void OnUpdate(TimeSpan time);
-
- public abstract void Dispose();
}
///
@@ -158,8 +156,6 @@ namespace ComputeSharp.Sample.SwapChain
}
}
- application.Dispose();
-
// Return this part of the WM_QUIT message to Windows
return (int)msg.wParam;
}