ShaderBundle.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Ryujinx.Graphics.GAL;
  2. using System;
  3. namespace Ryujinx.Graphics.Gpu.Shader
  4. {
  5. /// <summary>
  6. /// Represents a program composed of one or more shader stages (for graphics shaders),
  7. /// or a single shader (for compute shaders).
  8. /// </summary>
  9. class ShaderBundle : IDisposable
  10. {
  11. /// <summary>
  12. /// Host shader program object.
  13. /// </summary>
  14. public IProgram HostProgram { get; }
  15. /// <summary>
  16. /// Compiled shader for each shader stage.
  17. /// </summary>
  18. public ShaderCodeHolder[] Shaders { get; }
  19. /// <summary>
  20. /// Creates a new instance of the shader bundle.
  21. /// </summary>
  22. /// <param name="hostProgram">Host program with all the shader stages</param>
  23. /// <param name="shaders">Shaders</param>
  24. public ShaderBundle(IProgram hostProgram, params ShaderCodeHolder[] shaders)
  25. {
  26. HostProgram = hostProgram;
  27. Shaders = shaders;
  28. }
  29. /// <summary>
  30. /// Dispose of the host shader resources.
  31. /// </summary>
  32. public void Dispose()
  33. {
  34. HostProgram.Dispose();
  35. foreach (ShaderCodeHolder holder in Shaders)
  36. {
  37. holder?.HostShader?.Dispose();
  38. }
  39. }
  40. }
  41. }