diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs
index 87a93399..74480aa4 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Shaders/Runners/ContouredLayersRunner.cs
@@ -25,14 +25,17 @@ public sealed class ContouredLayersRunner : IShaderRunner
///
public bool TryExecute(IReadWriteTexture2D texture, TimeSpan timespan, object? parameter)
{
- if (this.texture is null)
+ if (this.texture is null ||
+ this.texture.GraphicsDevice != texture.GraphicsDevice)
{
string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Textures", "RustyMetal.png");
- this.texture = GraphicsDevice.Default.LoadReadOnlyTexture2D(filename);
+ this.texture?.Dispose();
+
+ this.texture = texture.GraphicsDevice.LoadReadOnlyTexture2D(filename);
}
- GraphicsDevice.Default.ForEach(texture, new ContouredLayers((float)timespan.TotalSeconds, this.texture));
+ texture.GraphicsDevice.ForEach(texture, new ContouredLayers((float)timespan.TotalSeconds, this.texture));
return true;
}
diff --git a/src/ComputeSharp.UI/ShaderRunner{T}.cs b/src/ComputeSharp.UI/ShaderRunner{T}.cs
index 98b84b35..967e8713 100644
--- a/src/ComputeSharp.UI/ShaderRunner{T}.cs
+++ b/src/ComputeSharp.UI/ShaderRunner{T}.cs
@@ -61,11 +61,11 @@ public sealed class ShaderRunner : IShaderRunner
{
if (this.shaderFactory is Func shaderFactory)
{
- GraphicsDevice.Default.ForEach(texture, this.shaderFactory(time));
+ texture.GraphicsDevice.ForEach(texture, this.shaderFactory(time));
}
else
{
- GraphicsDevice.Default.ForEach(texture, this.statefulShaderFactory!(time, parameter));
+ texture.GraphicsDevice.ForEach(texture, this.statefulShaderFactory!(time, parameter));
}
return true;