Switch shader runners to use texture-provided device

このコミットが含まれているのは:
Sergio Pedri committed 2022-01-06 22:59:51 +01:00
1 親 c5a31efd00
コミット b734baa34b
2ファイル変更
+8 -5

検索条件に一致するファイルはありません

+6 -3
ファイルの表示
@@ -25,14 +25,17 @@ public sealed class ContouredLayersRunner : IShaderRunner
/// <inheritdoc/>
public bool TryExecute(IReadWriteTexture2D<Float4> 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<Rgba32, Float4>(filename);
this.texture?.Dispose();
this.texture = texture.GraphicsDevice.LoadReadOnlyTexture2D<Rgba32, Float4>(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;
}
+2 -2
ファイルの表示
@@ -61,11 +61,11 @@ public sealed class ShaderRunner<T> : IShaderRunner
{
if (this.shaderFactory is Func<TimeSpan, T> 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;