PerformanceFrameHeaderVersion2.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // Copyright (c) 2019-2020 Ryujinx
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. //
  17. using System.Runtime.InteropServices;
  18. namespace Ryujinx.Audio.Renderer.Server.Performance
  19. {
  20. /// <summary>
  21. /// Implementation of <see cref="IPerformanceHeader"/> for performance metrics version 2.
  22. /// </summary>
  23. [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x30)]
  24. public struct PerformanceFrameHeaderVersion2 : IPerformanceHeader
  25. {
  26. /// <summary>
  27. /// The magic of the performance header.
  28. /// </summary>
  29. public uint Magic;
  30. /// <summary>
  31. /// The total count of entries in this frame.
  32. /// </summary>
  33. public int EntryCount;
  34. /// <summary>
  35. /// The total count of detailed entries in this frame.
  36. /// </summary>
  37. public int EntryDetailCount;
  38. /// <summary>
  39. /// The offset of the next performance header.
  40. /// </summary>
  41. public int NextOffset;
  42. /// <summary>
  43. /// The total time taken by all the commands profiled.
  44. /// </summary>
  45. public int TotalProcessingTime;
  46. /// <summary>
  47. /// The count of voices that were dropped.
  48. /// </summary>
  49. public uint VoiceDropCount;
  50. /// <summary>
  51. /// The start ticks of the <see cref="Dsp.AudioProcessor"/>. (before sending commands)
  52. /// </summary>
  53. public ulong StartRenderingTicks;
  54. /// <summary>
  55. /// The index of this performance frame.
  56. /// </summary>
  57. public uint Index;
  58. /// <summary>
  59. /// If set to true, the DSP is running behind.
  60. /// </summary>
  61. [MarshalAs(UnmanagedType.I1)]
  62. public bool IsDspRunningBehind;
  63. public int GetEntryCount()
  64. {
  65. return EntryCount;
  66. }
  67. public int GetEntryCountOffset()
  68. {
  69. return 4;
  70. }
  71. public int GetEntryDetailCount()
  72. {
  73. return EntryDetailCount;
  74. }
  75. public void SetDspRunningBehind(bool isRunningBehind)
  76. {
  77. IsDspRunningBehind = isRunningBehind;
  78. }
  79. public void SetEntryCount(int entryCount)
  80. {
  81. EntryCount = entryCount;
  82. }
  83. public void SetEntryDetailCount(int entryDetailCount)
  84. {
  85. EntryDetailCount = entryDetailCount;
  86. }
  87. public void SetIndex(uint index)
  88. {
  89. Index = index;
  90. }
  91. public void SetMagic(uint magic)
  92. {
  93. Magic = magic;
  94. }
  95. public void SetNextOffset(int nextOffset)
  96. {
  97. NextOffset = nextOffset;
  98. }
  99. public void SetStartRenderingTicks(ulong startTicks)
  100. {
  101. StartRenderingTicks = startTicks;
  102. }
  103. public void SetTotalProcessingTime(int totalProcessingTime)
  104. {
  105. TotalProcessingTime = totalProcessingTime;
  106. }
  107. public void SetVoiceDropCount(uint voiceCount)
  108. {
  109. VoiceDropCount = voiceCount;
  110. }
  111. }
  112. }