ImageArray.cs
1 using OpenTK.Graphics.OpenGL; 2 using Ryujinx.Graphics.GAL; 3 4 namespace Ryujinx.Graphics.OpenGL.Image 5 { 6 class ImageArray : IImageArray 7 { 8 private record struct TextureRef 9 { 10 public int Handle; 11 public Format Format; 12 } 13 14 private readonly TextureRef[] _images; 15 16 public ImageArray(int size) 17 { 18 _images = new TextureRef[size]; 19 } 20 21 public void SetImages(int index, ITexture[] images) 22 { 23 for (int i = 0; i < images.Length; i++) 24 { 25 ITexture image = images[i]; 26 27 if (image is TextureBase imageBase) 28 { 29 _images[index + i].Handle = imageBase.Handle; 30 _images[index + i].Format = imageBase.Format; 31 } 32 else 33 { 34 _images[index + i].Handle = 0; 35 } 36 } 37 } 38 39 public void Bind(int baseBinding) 40 { 41 for (int i = 0; i < _images.Length; i++) 42 { 43 if (_images[i].Handle == 0) 44 { 45 GL.BindImageTexture(baseBinding + i, 0, 0, true, 0, TextureAccess.ReadWrite, SizedInternalFormat.Rgba8); 46 } 47 else 48 { 49 SizedInternalFormat format = FormatTable.GetImageFormat(_images[i].Format); 50 51 if (format != 0) 52 { 53 GL.BindImageTexture(baseBinding + i, _images[i].Handle, 0, true, 0, TextureAccess.ReadWrite, format); 54 } 55 } 56 } 57 } 58 59 public void Dispose() 60 { 61 } 62 } 63 }