Merge pull request #889 from Sergio0694/dev/use-generated-canvas-effect-property

Use '[GeneratedCanvasEffectProperty]' in samples
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2024-12-21 17:12:33 +01:00
コミット e4a8770d35
9ファイル変更
+31 -110

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

+1
ファイルの表示
@@ -50,6 +50,7 @@
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.Core\ComputeSharp.Core.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.WinUI.SourceGenerators\ComputeSharp.D2D1.WinUI.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.WinUI\ComputeSharp.D2D1.WinUI.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
</ItemGroup>
+7 -19
ファイルの表示
@@ -14,29 +14,17 @@ public sealed partial class HelloWorldEffect : CanvasEffect
/// </summary>
private static readonly CanvasEffectNode<PixelShaderEffect<Shader>> EffectNode = new();
/// <summary><inheritdoc cref="Shader(float, Int2)" path="/param[@name='time']/node()"/></summary>
private float time;
/// <summary><inheritdoc cref="Shader(float, Int2)" path="/param[@name='dispatchSize']/node()"/></summary>
private Rect dispatchArea;
/// <summary>
/// Gets or sets the current time since the start of the application.
/// </summary>
public float Time
{
get => this.time;
set => SetPropertyAndInvalidateEffectGraph(ref this.time, value);
}
[GeneratedCanvasEffectProperty]
public partial float Time { get; set; }
/// <summary>
/// Gets or sets the dispatch area for the current output.
/// </summary>
public Rect DispatchArea
{
get => this.dispatchArea;
set => SetPropertyAndInvalidateEffectGraph(ref this.dispatchArea, value);
}
[GeneratedCanvasEffectProperty]
public partial Rect DispatchArea { get; set; }
/// <inheritdoc/>
protected override void BuildEffectGraph(CanvasEffectGraph effectGraph)
@@ -48,10 +36,10 @@ public sealed partial class HelloWorldEffect : CanvasEffect
protected override void ConfigureEffectGraph(CanvasEffectGraph effectGraph)
{
effectGraph.GetNode(EffectNode).ConstantBuffer = new Shader(
time: this.time,
time: Time,
dispatchSize: new int2(
x: (int)double.Round(this.dispatchArea.Width),
y: (int)double.Round(this.dispatchArea.Height)));
x: (int)double.Round(DispatchArea.Width),
y: (int)double.Round(DispatchArea.Height)));
}
/// <summary>
+6 -30
ファイルの表示
@@ -10,47 +10,23 @@ namespace ComputeSharp.SwapChain.D2D1.Backend;
/// </summary>
internal abstract partial class PixelShaderEffect : CanvasEffect
{
/// <summary>
/// The current elapsed time.
/// </summary>
private TimeSpan elapsedTime;
/// <summary>
/// The current screen width in raw pixels.
/// </summary>
private int screenWidth;
/// <summary>
/// The current screen height in raw pixels.
/// </summary>
private int screenHeight;
/// <summary>
/// Gets or sets the total elapsed time.
/// </summary>
public TimeSpan ElapsedTime
{
get => this.elapsedTime;
set => SetPropertyAndInvalidateEffectGraph(ref this.elapsedTime, value);
}
[GeneratedCanvasEffectProperty]
public partial TimeSpan ElapsedTime { get; set; }
/// <summary>
/// Gets or sets the screen width in raw pixels.
/// </summary>
public int ScreenWidth
{
get => this.screenWidth;
set => SetPropertyAndInvalidateEffectGraph(ref this.screenWidth, value);
}
[GeneratedCanvasEffectProperty]
public partial int ScreenWidth { get; set; }
/// <summary>
/// Gets or sets the screen height in raw pixels.
/// </summary>
public int ScreenHeight
{
get => this.screenHeight;
set => SetPropertyAndInvalidateEffectGraph(ref this.screenHeight, value);
}
[GeneratedCanvasEffectProperty]
public partial int ScreenHeight { get; set; }
/// <summary>
/// An effect for an animated pixel shader.
+1
ファイルの表示
@@ -74,6 +74,7 @@
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" SetPlatform="Platform=AnyCPU" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.Core\ComputeSharp.Core.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" SetPlatform="Platform=AnyCPU" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.WinUI.SourceGenerators\ComputeSharp.D2D1.WinUI.SourceGenerators.csproj" SetPlatform="Platform=AnyCPU" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.WinUI\ComputeSharp.D2D1.WinUI.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
</ItemGroup>
+6 -30
ファイルの表示
@@ -10,47 +10,23 @@ namespace ComputeSharp.SwapChain.D2D1.Backend;
/// </summary>
internal abstract partial class PixelShaderEffect : CanvasEffect
{
/// <summary>
/// The current elapsed time.
/// </summary>
private TimeSpan elapsedTime;
/// <summary>
/// The current screen width in raw pixels.
/// </summary>
private int screenWidth;
/// <summary>
/// The current screen height in raw pixels.
/// </summary>
private int screenHeight;
/// <summary>
/// Gets or sets the total elapsed time.
/// </summary>
public TimeSpan ElapsedTime
{
get => this.elapsedTime;
set => SetPropertyAndInvalidateEffectGraph(ref this.elapsedTime, value);
}
[GeneratedCanvasEffectProperty]
public partial TimeSpan ElapsedTime { get; set; }
/// <summary>
/// Gets or sets the screen width in raw pixels.
/// </summary>
public int ScreenWidth
{
get => this.screenWidth;
set => SetPropertyAndInvalidateEffectGraph(ref this.screenWidth, value);
}
[GeneratedCanvasEffectProperty]
public partial int ScreenWidth { get; set; }
/// <summary>
/// Gets or sets the screen height in raw pixels.
/// </summary>
public int ScreenHeight
{
get => this.screenHeight;
set => SetPropertyAndInvalidateEffectGraph(ref this.screenHeight, value);
}
[GeneratedCanvasEffectProperty]
public partial int ScreenHeight { get; set; }
/// <summary>
/// An effect for an animated pixel shader.
+2 -1
ファイルの表示
@@ -41,9 +41,10 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.Uwp.SourceGenerators\ComputeSharp.D2D1.Uwp.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.Uwp\ComputeSharp.D2D1.Uwp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
</ItemGroup>
<!-- Shared projects for the D2D1 shaders -->
+6 -30
ファイルの表示
@@ -14,47 +14,23 @@ namespace ComputeSharp.SwapChain.Core.Shaders;
/// </summary>
public abstract partial class PixelShaderEffect : CanvasEffect
{
/// <summary>
/// The current elapsed time.
/// </summary>
private TimeSpan elapsedTime;
/// <summary>
/// The current screen width in raw pixels.
/// </summary>
private int screenWidth;
/// <summary>
/// The current screen height in raw pixels.
/// </summary>
private int screenHeight;
/// <summary>
/// Gets or sets the total elapsed time.
/// </summary>
public TimeSpan ElapsedTime
{
get => this.elapsedTime;
set => SetPropertyAndInvalidateEffectGraph(ref this.elapsedTime, value);
}
[GeneratedCanvasEffectProperty]
public partial TimeSpan ElapsedTime { get; set; }
/// <summary>
/// Gets or sets the screen width in raw pixels.
/// </summary>
public int ScreenWidth
{
get => this.screenWidth;
set => SetPropertyAndInvalidateEffectGraph(ref this.screenWidth, value);
}
[GeneratedCanvasEffectProperty]
public partial int ScreenWidth { get; set; }
/// <summary>
/// Gets or sets the screen height in raw pixels.
/// </summary>
public int ScreenHeight
{
get => this.screenHeight;
set => SetPropertyAndInvalidateEffectGraph(ref this.screenHeight, value);
}
[GeneratedCanvasEffectProperty]
public partial int ScreenHeight { get; set; }
/// <summary>
/// An effect for an animated pixel shader.
+1
ファイルの表示
@@ -59,6 +59,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.Uwp.SourceGenerators\ComputeSharp.D2D1.Uwp.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.Uwp\ComputeSharp.D2D1.Uwp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
+1
ファイルの表示
@@ -76,6 +76,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.WinUI.SourceGenerators\ComputeSharp.D2D1.WinUI.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.WinUI\ComputeSharp.D2D1.WinUI.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />