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