using System; using ComputeSharp.__Internals; #pragma warning disable CS0618 namespace ComputeSharp.WinUI { /// /// An implementation powered by a supplied shader type. /// /// The type of shader to use to render frames. public sealed class ShaderRunner : IShaderRunner where T : struct, IPixelShader, IShader { /// /// The instance used to create shaders to run. /// private readonly Func shaderFactory; /// /// Creates a new instance that will create shader instances with /// the default constructor. Only use this constructor if the shader doesn't require any additional /// resources or other parameters being initialized before being dispatched on the GPU. /// public ShaderRunner() { this.shaderFactory = static _ => default; } /// /// Creates a new instance. /// /// The instance used to create shaders to run. public ShaderRunner(Func shaderFactory) { this.shaderFactory = shaderFactory; } /// public void Execute(IReadWriteTexture2D texture, TimeSpan time) { Gpu.Default.ForEach(texture, this.shaderFactory(time)); } } }