InputSurface.cs
1 using System; 2 3 namespace Ryujinx.Graphics.Vic.Image 4 { 5 ref struct RentedBuffer 6 { 7 public static RentedBuffer Empty => new(Span<byte>.Empty, -1); 8 9 public Span<byte> Data; 10 public int Index; 11 12 public RentedBuffer(Span<byte> data, int index) 13 { 14 Data = data; 15 Index = index; 16 } 17 18 public readonly void Return(BufferPool<byte> pool) 19 { 20 if (Index != -1) 21 { 22 pool.Return(Index); 23 } 24 } 25 } 26 27 ref struct InputSurface 28 { 29 public ReadOnlySpan<byte> Buffer0; 30 public ReadOnlySpan<byte> Buffer1; 31 public ReadOnlySpan<byte> Buffer2; 32 33 public int Buffer0Index; 34 public int Buffer1Index; 35 public int Buffer2Index; 36 37 public int Width; 38 public int Height; 39 40 public int UvWidth; 41 public int UvHeight; 42 43 public void Initialize() 44 { 45 Buffer0Index = -1; 46 Buffer1Index = -1; 47 Buffer2Index = -1; 48 } 49 50 public void SetBuffer0(RentedBuffer buffer) 51 { 52 Buffer0 = buffer.Data; 53 Buffer0Index = buffer.Index; 54 } 55 56 public void SetBuffer1(RentedBuffer buffer) 57 { 58 Buffer1 = buffer.Data; 59 Buffer1Index = buffer.Index; 60 } 61 62 public void SetBuffer2(RentedBuffer buffer) 63 { 64 Buffer2 = buffer.Data; 65 Buffer2Index = buffer.Index; 66 } 67 68 public readonly void Return(BufferPool<byte> pool) 69 { 70 if (Buffer0Index != -1) 71 { 72 pool.Return(Buffer0Index); 73 } 74 75 if (Buffer1Index != -1) 76 { 77 pool.Return(Buffer1Index); 78 } 79 80 if (Buffer2Index != -1) 81 { 82 pool.Return(Buffer2Index); 83 } 84 } 85 } 86 }