Update samples to use new EffectGraph APIs
このコミットが含まれているのは:
1 親
4db990d03b
コミット
3fdd315d88
3ファイル変更
+26
-64
検索条件に一致するファイルはありません
@@ -5,7 +5,6 @@ using ComputeSharp.D2D1.Uwp;
|
||||
#else
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
#endif
|
||||
using Microsoft.Graphics.Canvas;
|
||||
|
||||
#nullable enable
|
||||
|
||||
@@ -65,16 +64,16 @@ public abstract class PixelShaderEffect : CanvasEffect
|
||||
public sealed class For<T> : PixelShaderEffect
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="PixelShaderEffect{T}"/> node in use.
|
||||
/// </summary>
|
||||
private static readonly EffectNode<PixelShaderEffect<T>> Effect = new();
|
||||
|
||||
/// <summary>
|
||||
/// The <typeparamref name="T"/> factory to use.
|
||||
/// </summary>
|
||||
private readonly Factory factory;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PixelShaderEffect{T}"/> instance in use.
|
||||
/// </summary>
|
||||
private PixelShaderEffect<T>? effect;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="For{T}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -85,28 +84,15 @@ public abstract class PixelShaderEffect : CanvasEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override ICanvasImage BuildEffectGraph()
|
||||
protected override void BuildEffectGraph(EffectGraph effectGraph)
|
||||
{
|
||||
this.effect = new PixelShaderEffect<T>();
|
||||
|
||||
return this.effect;
|
||||
effectGraph.RegisterAndSetOutputNode(Effect, new PixelShaderEffect<T>());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void ConfigureEffectGraph()
|
||||
protected override void ConfigureEffectGraph(EffectGraph effectGraph)
|
||||
{
|
||||
this.effect!.ConstantBuffer = this.factory(ElapsedTime, ScreenWidth, ScreenHeight);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
this.effect?.Dispose();
|
||||
}
|
||||
effectGraph.GetNode(Effect).ConstantBuffer = this.factory(ElapsedTime, ScreenWidth, ScreenHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+8
-19
@@ -8,7 +8,6 @@ using ComputeSharp.D2D1.Uwp;
|
||||
using ComputeSharp.D2D1.WinUI;
|
||||
#endif
|
||||
using ComputeSharp.SwapChain.Shaders.D2D1;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
#nullable enable
|
||||
@@ -21,12 +20,12 @@ namespace ComputeSharp.SwapChain.Core.Shaders.Runners;
|
||||
public sealed class D2D1ContouredLayersEffect : PixelShaderEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The reusable <see cref="PixelShaderEffect{T}"/> instance to use to render frames.
|
||||
/// The reusable <see cref="PixelShaderEffect{T}"/> node to use to render frames.
|
||||
/// </summary>
|
||||
private PixelShaderEffect<ContouredLayers>? pixelShaderEffect;
|
||||
private static readonly EffectNode<PixelShaderEffect<ContouredLayers>> PixelShaderEffect = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override unsafe ICanvasImage BuildEffectGraph()
|
||||
protected override unsafe void BuildEffectGraph(EffectGraph effectGraph)
|
||||
{
|
||||
string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Textures", "RustyMetal.png");
|
||||
|
||||
@@ -56,25 +55,15 @@ public sealed class D2D1ContouredLayersEffect : PixelShaderEffect
|
||||
strides: stackalloc uint[] { (uint)strideInBytes });
|
||||
|
||||
// Create the new pixel shader effect
|
||||
this.pixelShaderEffect = new PixelShaderEffect<ContouredLayers>() { ResourceTextureManagers = { [0] = resourceTextureManager } };
|
||||
PixelShaderEffect<ContouredLayers> pixelShaderEffect = new() { ResourceTextureManagers = { [0] = resourceTextureManager } };
|
||||
|
||||
return this.pixelShaderEffect;
|
||||
// Register the pixel shader effect as the output node in the effect graph
|
||||
effectGraph.RegisterAndSetOutputNode(PixelShaderEffect, pixelShaderEffect);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void ConfigureEffectGraph()
|
||||
protected override void ConfigureEffectGraph(EffectGraph effectGraph)
|
||||
{
|
||||
this.pixelShaderEffect!.ConstantBuffer = new ContouredLayers((float)ElapsedTime.TotalSeconds, new int2(ScreenWidth, ScreenHeight));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
this.pixelShaderEffect?.Dispose();
|
||||
}
|
||||
effectGraph.GetNode(PixelShaderEffect).ConstantBuffer = new ContouredLayers((float)ElapsedTime.TotalSeconds, new int2(ScreenWidth, ScreenHeight));
|
||||
}
|
||||
}
|
||||
@@ -59,16 +59,16 @@ internal abstract class PixelShaderEffect : CanvasEffect
|
||||
public sealed class For<T> : PixelShaderEffect
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="PixelShaderEffect{T}"/> node in use.
|
||||
/// </summary>
|
||||
private static readonly EffectNode<PixelShaderEffect<T>> Effect = new();
|
||||
|
||||
/// <summary>
|
||||
/// The <typeparamref name="T"/> factory to use.
|
||||
/// </summary>
|
||||
private readonly Factory factory;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PixelShaderEffect{T}"/> instance in use.
|
||||
/// </summary>
|
||||
private PixelShaderEffect<T>? effect;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="For{T}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -79,28 +79,15 @@ internal abstract class PixelShaderEffect : CanvasEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override ICanvasImage BuildEffectGraph()
|
||||
protected override void BuildEffectGraph(EffectGraph effectGraph)
|
||||
{
|
||||
this.effect = new PixelShaderEffect<T>();
|
||||
|
||||
return this.effect;
|
||||
effectGraph.RegisterAndSetOutputNode(Effect, new PixelShaderEffect<T>());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void ConfigureEffectGraph()
|
||||
protected override void ConfigureEffectGraph(EffectGraph effectGraph)
|
||||
{
|
||||
this.effect!.ConstantBuffer = this.factory(ElapsedTime, ScreenWidth, ScreenHeight);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
this.effect?.Dispose();
|
||||
}
|
||||
effectGraph.GetNode(Effect).ConstantBuffer = this.factory(ElapsedTime, ScreenWidth, ScreenHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする