/ src / Ryujinx.Graphics.OpenGL / Image / TextureArray.cs
TextureArray.cs
 1  using Ryujinx.Graphics.GAL;
 2  
 3  namespace Ryujinx.Graphics.OpenGL.Image
 4  {
 5      class TextureArray : ITextureArray
 6      {
 7          private record struct TextureRef
 8          {
 9              public TextureBase Texture;
10              public Sampler Sampler;
11          }
12  
13          private readonly TextureRef[] _textureRefs;
14  
15          public TextureArray(int size)
16          {
17              _textureRefs = new TextureRef[size];
18          }
19  
20          public void SetSamplers(int index, ISampler[] samplers)
21          {
22              for (int i = 0; i < samplers.Length; i++)
23              {
24                  _textureRefs[index + i].Sampler = samplers[i] as Sampler;
25              }
26          }
27  
28          public void SetTextures(int index, ITexture[] textures)
29          {
30              for (int i = 0; i < textures.Length; i++)
31              {
32                  _textureRefs[index + i].Texture = textures[i] as TextureBase;
33              }
34          }
35  
36          public void Bind(int baseBinding)
37          {
38              for (int i = 0; i < _textureRefs.Length; i++)
39              {
40                  if (_textureRefs[i].Texture != null)
41                  {
42                      _textureRefs[i].Texture.Bind(baseBinding + i);
43                      _textureRefs[i].Sampler?.Bind(baseBinding + i);
44                  }
45                  else
46                  {
47                      TextureBase.ClearBinding(baseBinding + i);
48                  }
49              }
50          }
51  
52          public void Dispose()
53          {
54          }
55      }
56  }