EffectContext.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.Diagnostics;
  18. namespace Ryujinx.Audio.Renderer.Server.Effect
  19. {
  20. /// <summary>
  21. /// Effect context.
  22. /// </summary>
  23. public class EffectContext
  24. {
  25. /// <summary>
  26. /// Storage for <see cref="BaseEffect"/>.
  27. /// </summary>
  28. private BaseEffect[] _effects;
  29. /// <summary>
  30. /// The total effect count.
  31. /// </summary>
  32. private uint _effectCount;
  33. /// <summary>
  34. /// Create a new <see cref="EffectContext"/>.
  35. /// </summary>
  36. public EffectContext()
  37. {
  38. _effects = null;
  39. _effectCount = 0;
  40. }
  41. /// <summary>
  42. /// Initialize the <see cref="EffectContext"/>.
  43. /// </summary>
  44. /// <param name="effectCount">The total effect count.</param>
  45. public void Initialize(uint effectCount)
  46. {
  47. _effectCount = effectCount;
  48. _effects = new BaseEffect[effectCount];
  49. for (int i = 0; i < _effectCount; i++)
  50. {
  51. _effects[i] = new BaseEffect();
  52. }
  53. }
  54. /// <summary>
  55. /// Get the total effect count.
  56. /// </summary>
  57. /// <returns>The total effect count.</returns>
  58. public uint GetCount()
  59. {
  60. return _effectCount;
  61. }
  62. /// <summary>
  63. /// Get a reference to a <see cref="BaseEffect"/> at the given <paramref name="index"/>.
  64. /// </summary>
  65. /// <param name="index">The index to use.</param>
  66. /// <returns>A reference to a <see cref="BaseEffect"/> at the given <paramref name="index"/>.</returns>
  67. public ref BaseEffect GetEffect(int index)
  68. {
  69. Debug.Assert(index >= 0 && index < _effectCount);
  70. return ref _effects[index];
  71. }
  72. }
  73. }