using System; #if WINDOWS_UWP namespace ComputeSharp.Uwp; #else namespace ComputeSharp.WinUI; #endif /// /// 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 { /// /// 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) { GraphicsDevice.Default.ForEach(texture, this.shaderFactory(time)); } }