PerformanceEntryAddresses.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // Copyright (c) 2019-2021 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;
  18. namespace Ryujinx.Audio.Renderer.Server.Performance
  19. {
  20. /// <summary>
  21. /// Information used by the performance command to store informations in the performance entry.
  22. /// </summary>
  23. public class PerformanceEntryAddresses
  24. {
  25. /// <summary>
  26. /// The memory storing the performance entry.
  27. /// </summary>
  28. public Memory<int> BaseMemory;
  29. /// <summary>
  30. /// The offset to the start time field.
  31. /// </summary>
  32. public uint StartTimeOffset;
  33. /// <summary>
  34. /// The offset to the entry count field.
  35. /// </summary>
  36. public uint EntryCountOffset;
  37. /// <summary>
  38. /// The offset to the processing time field.
  39. /// </summary>
  40. public uint ProcessingTimeOffset;
  41. /// <summary>
  42. /// Increment the entry count.
  43. /// </summary>
  44. public void IncrementEntryCount()
  45. {
  46. BaseMemory.Span[(int)EntryCountOffset / 4]++;
  47. }
  48. /// <summary>
  49. /// Set the start time in the entry.
  50. /// </summary>
  51. /// <param name="startTimeNano">The start time in nanoseconds.</param>
  52. public void SetStartTime(ulong startTimeNano)
  53. {
  54. BaseMemory.Span[(int)StartTimeOffset / 4] = (int)(startTimeNano / 1000);
  55. }
  56. /// <summary>
  57. /// Set the processing time in the entry.
  58. /// </summary>
  59. /// <param name="endTimeNano">The end time in nanoseconds.</param>
  60. public void SetProcessingTime(ulong endTimeNano)
  61. {
  62. BaseMemory.Span[(int)ProcessingTimeOffset / 4] = (int)(endTimeNano / 1000) - BaseMemory.Span[(int)StartTimeOffset / 4];
  63. }
  64. }
  65. }