ShaderDumpPaths.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Ryujinx.Graphics.Shader;
  2. namespace Ryujinx.Graphics.Gpu.Shader
  3. {
  4. /// <summary>
  5. /// Paths where shader code was dumped on disk.
  6. /// </summary>
  7. readonly struct ShaderDumpPaths
  8. {
  9. /// <summary>
  10. /// Path where the full shader code with header was dumped, or null if not dumped.
  11. /// </summary>
  12. public string FullPath { get; }
  13. /// <summary>
  14. /// Path where the shader code without header was dumped, or null if not dumped.
  15. /// </summary>
  16. public string CodePath { get; }
  17. /// <summary>
  18. /// True if the shader was dumped, false otherwise.
  19. /// </summary>
  20. public bool HasPath => FullPath != null && CodePath != null;
  21. /// <summary>
  22. /// Creates a new shader dumps path structure.
  23. /// </summary>
  24. /// <param name="fullPath">Path where the full shader code with header was dumped, or null if not dumped</param>
  25. /// <param name="codePath">Path where the shader code without header was dumped, or null if not dumped</param>
  26. public ShaderDumpPaths(string fullPath, string codePath)
  27. {
  28. FullPath = fullPath;
  29. CodePath = codePath;
  30. }
  31. /// <summary>
  32. /// Prepends the shader paths on the program source, as a comment.
  33. /// </summary>
  34. /// <param name="program">Program to prepend into</param>
  35. public void Prepend(ShaderProgram program)
  36. {
  37. if (HasPath)
  38. {
  39. program.Prepend("// " + CodePath);
  40. program.Prepend("// " + FullPath);
  41. }
  42. }
  43. }
  44. }