ShaderCodeAccessor.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using Ryujinx.Graphics.Gpu.Memory;
  2. using Ryujinx.Graphics.Gpu.Shader.HashTable;
  3. using System;
  4. namespace Ryujinx.Graphics.Gpu.Shader
  5. {
  6. /// <summary>
  7. /// Shader code accessor.
  8. /// </summary>
  9. readonly struct ShaderCodeAccessor : IDataAccessor
  10. {
  11. private readonly MemoryManager _memoryManager;
  12. private readonly ulong _baseAddress;
  13. /// <summary>
  14. /// Creates a new shader code accessor.
  15. /// </summary>
  16. /// <param name="memoryManager">Memory manager used to access the shader code</param>
  17. /// <param name="baseAddress">Base address of the shader in memory</param>
  18. public ShaderCodeAccessor(MemoryManager memoryManager, ulong baseAddress)
  19. {
  20. _memoryManager = memoryManager;
  21. _baseAddress = baseAddress;
  22. }
  23. /// <inheritdoc/>
  24. public ReadOnlySpan<byte> GetSpan(int offset, int length)
  25. {
  26. return _memoryManager.GetSpanMapped(_baseAddress + (ulong)offset, length);
  27. }
  28. }
  29. }