using Ryujinx.Graphics.GAL;
using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
/// <summary>
/// Represents a program composed of one or more shader stages (for graphics shaders),
/// or a single shader (for compute shaders).
/// </summary>
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.
/// <param name="hostProgram">Host program with all the shader stages</param>
/// <param name="specializationState">GPU state used to create this version of the shader</param>
/// <param name="shaders">Shaders</param>
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();