using Ryujinx.Graphics.GAL; using System; namespace Ryujinx.Graphics.Gpu.Shader { /// /// Represents a program composed of one or more shader stages (for graphics shaders), /// or a single shader (for compute shaders). /// class CachedShaderProgram : IDisposable { /// /// Host shader program object. /// public IProgram HostProgram { get; } /// /// GPU state used to create this version of the shader. /// public ShaderSpecializationState SpecializationState { get; } /// /// Compiled shader for each shader stage. /// public CachedShaderStage[] Shaders { get; } /// /// Cached shader bindings, ready for placing into the bindings manager. /// public CachedShaderBindings Bindings { get; } /// /// Creates a new instance of the shader bundle. /// /// Host program with all the shader stages /// GPU state used to create this version of the shader /// Shaders public CachedShaderProgram(IProgram hostProgram, ShaderSpecializationState specializationState, params CachedShaderStage[] shaders) { HostProgram = hostProgram; SpecializationState = specializationState; Shaders = shaders; SpecializationState.Prepare(shaders); Bindings = new CachedShaderBindings(shaders.Length == 1, shaders); } /// /// Dispose of the host shader resources. /// public void Dispose() { HostProgram.Dispose(); } } }