Wire up D2D1 frames renderer in UWP sample

このコミットが含まれているのは:
Sergio Pedri committed 2023-01-21 20:03:25 +01:00
1 親 5369832bd7
コミット 162b46ed41
3ファイル変更
+59 -22

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

+41 -11
ファイルの表示
@@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ComputeSharp.SwapChain.Core.Constants;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.Shaders;
using ComputeSharp.SwapChain.Core.Shaders.Runners;
using ComputeSharp.SwapChain.Shaders;
#if WINDOWS_UWP
@@ -102,17 +103,46 @@ public sealed partial class MainViewModel : ObservableObject
/// </summary>
public IReadOnlyList<ShaderRunnerViewModel> ComputeShaderOptions { get; } = new ShaderRunnerViewModel[]
{
new(typeof(ColorfulInfinity), new ShaderRunner<ColorfulInfinity>(static time => new((float)time.TotalSeconds))),
new(typeof(ExtrudedTruchetPattern),new ShaderRunner<ExtrudedTruchetPattern>(static time => new((float)time.TotalSeconds))),
new(typeof(FractalTiling),new ShaderRunner<FractalTiling>(static time => new((float)time.TotalSeconds))),
new(typeof(MengerJourney),new ShaderRunner<MengerJourney>(static time => new((float)time.TotalSeconds))),
new(typeof(Octagrams),new ShaderRunner<Octagrams>(static time => new((float)time.TotalSeconds))),
new(typeof(ProteanClouds),new ShaderRunner<ProteanClouds>(static time => new((float)time.TotalSeconds))),
new(typeof(TwoTiledTruchet),new ShaderRunner<TwoTiledTruchet>(static time => new((float)time.TotalSeconds))),
new(typeof(PyramidPattern),new ShaderRunner<PyramidPattern>(static time => new((float)time.TotalSeconds))),
new(typeof(TriangleGridContouring),new ShaderRunner<TriangleGridContouring>(static time => new((float)time.TotalSeconds))),
new(typeof(ContouredLayers),new ContouredLayersRunner()),
new(typeof(TerracedHills),new ShaderRunner<TerracedHills>(static time => new((float)time.TotalSeconds))),
new(
typeof(ColorfulInfinity),
new ShaderRunner<ColorfulInfinity>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.ColorfulInfinity>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(FractalTiling),
new ShaderRunner<FractalTiling>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.FractalTiling>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(MengerJourney),
new ShaderRunner<MengerJourney>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.MengerJourney>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(Octagrams),
new ShaderRunner<Octagrams>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.Octagrams>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(ProteanClouds),
new ShaderRunner<ProteanClouds>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.ProteanClouds>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(TwoTiledTruchet),
new ShaderRunner<TwoTiledTruchet>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.TwoTiledTruchet>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(PyramidPattern),
new ShaderRunner<PyramidPattern>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.PyramidPattern>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(TriangleGridContouring),
new ShaderRunner<TriangleGridContouring>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.TriangleGridContouring>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(ContouredLayers),
new ContouredLayersRunner(),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.HelloWorld>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
new(
typeof(TerracedHills),
new ShaderRunner<TerracedHills>(static time => new((float)time.TotalSeconds)),
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.TerracedHills>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
};
private ShaderRunnerViewModel selectedComputeShader;
+13 -10
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
using ComputeSharp.SwapChain.Core.Shaders;
#if WINDOWS_UWP
using ComputeSharp.Uwp;
#else
@@ -11,17 +12,25 @@ namespace ComputeSharp.SwapChain.Core.ViewModels;
/// <summary>
/// A viewmodel for a compute shader.
/// </summary>
public sealed class ShaderRunnerViewModel : ObservableObject
public sealed partial class ShaderRunnerViewModel : ObservableObject
{
/// <summary>
/// Gets or sets whether the current shader is selected.
/// </summary>
[ObservableProperty]
private bool isSelected;
/// <summary>
/// Creates a new <see cref="ShaderRunnerViewModel"/> instance.
/// </summary>
/// <param name="shaderType">The <see cref="Type"/> instance for the actual shader to execute.</param>
/// <param name="shaderRunner">The <see cref="IShaderRunner"/> instance to execute.</param>
public ShaderRunnerViewModel(Type shaderType, IShaderRunner shaderRunner)
/// <param name="d2D1ShaderRunner">The <see cref="ID2D1ShaderRunner"/> instance to execute.</param>
public ShaderRunnerViewModel(Type shaderType, IShaderRunner shaderRunner, ID2D1ShaderRunner d2D1ShaderRunner)
{
ShaderType = shaderType;
ShaderRunner = shaderRunner;
D2D1ShaderRunner = d2D1ShaderRunner;
}
/// <summary>
@@ -34,14 +43,8 @@ public sealed class ShaderRunnerViewModel : ObservableObject
/// </summary>
public IShaderRunner ShaderRunner { get; }
private bool isSelected;
/// <summary>
/// Gets or sets whether the current shader is selected.
/// Gets the <see cref="ID2D1ShaderRunner"/> instance to execute.
/// </summary>
public bool IsSelected
{
get => this.isSelected;
set => SetProperty(ref this.isSelected, value);
}
public ID2D1ShaderRunner D2D1ShaderRunner { get; }
}