diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2019-12-31 19:37:00 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | 6e092c05584ccbbd548ac26c056c1a7edfa6c1a0 (patch) | |
| tree | 6f2856b448fca7beb721d49ed28160054388c7fc | |
| parent | 9bfb373bdf85178ef319fa4d107ae20d0a2d4a04 (diff) | |
More code cleanup
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/Texture.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/Buffer.cs | 22 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/IRange.cs | 3 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/RangeList.cs | 2 |
4 files changed, 13 insertions, 16 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index 076718e5..4bbefd0b 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// <summary> /// Represents a cached GPU texture. /// </summary> - class Texture : IRange<Texture>, IDisposable + class Texture : IRange, IDisposable { private GpuContext _context; diff --git a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index 99818bc8..8af61d3d 100644 --- a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -6,16 +6,14 @@ namespace Ryujinx.Graphics.Gpu.Memory /// <summary> /// Buffer, used to store vertex and index data, uniform and storage buffers, and others. /// </summary> - class Buffer : IRange<Buffer>, IDisposable + class Buffer : IRange, IDisposable { - private GpuContext _context; - - private IBuffer _buffer; + private readonly GpuContext _context; /// <summary> /// Host buffer object. /// </summary> - public IBuffer HostBuffer => _buffer; + public IBuffer HostBuffer { get; } /// <summary> /// Start address of the buffer in guest memory. @@ -46,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Memory Address = address; Size = size; - _buffer = context.Renderer.CreateBuffer((int)size); + HostBuffer = context.Renderer.CreateBuffer((int)size); _sequenceNumbers = new int[size / MemoryManager.PageSize]; @@ -64,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { int offset = (int)(address - Address); - return new BufferRange(_buffer, offset, (int)size); + return new BufferRange(HostBuffer, offset, (int)size); } /// <summary> @@ -121,7 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Memory int offset = (int)(mAddress - Address); - _buffer.SetData(offset, _context.PhysicalMemory.Read(mAddress, mSize)); + HostBuffer.SetData(offset, _context.PhysicalMemory.Read(mAddress, mSize)); } } @@ -132,7 +130,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// <param name="dstOffset">The offset of the destination buffer to copy into</param> public void CopyTo(Buffer destination, int dstOffset) { - _buffer.CopyTo(destination._buffer, 0, dstOffset, (int)Size); + HostBuffer.CopyTo(destination.HostBuffer, 0, dstOffset, (int)Size); } /// <summary> @@ -145,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { int offset = (int)(address - Address); - byte[] data = _buffer.GetData(offset, (int)size); + byte[] data = HostBuffer.GetData(offset, (int)size); _context.PhysicalMemory.Write(address, data); } @@ -155,7 +153,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// </summary> public void Invalidate() { - _buffer.SetData(0, _context.PhysicalMemory.Read(Address, Size)); + HostBuffer.SetData(0, _context.PhysicalMemory.Read(Address, Size)); } /// <summary> @@ -163,7 +161,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// </summary> public void Dispose() { - _buffer.Dispose(); + HostBuffer.Dispose(); } } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/Memory/IRange.cs b/Ryujinx.Graphics.Gpu/Memory/IRange.cs index 6d275d3f..9d5eee0b 100644 --- a/Ryujinx.Graphics.Gpu/Memory/IRange.cs +++ b/Ryujinx.Graphics.Gpu/Memory/IRange.cs @@ -3,8 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// <summary> /// Range of memory. /// </summary> - /// <typeparam name="T">GPU resource type</typeparam> - interface IRange<T> + interface IRange { ulong Address { get; } ulong Size { get; } diff --git a/Ryujinx.Graphics.Gpu/Memory/RangeList.cs b/Ryujinx.Graphics.Gpu/Memory/RangeList.cs index 75be1cf2..638108fe 100644 --- a/Ryujinx.Graphics.Gpu/Memory/RangeList.cs +++ b/Ryujinx.Graphics.Gpu/Memory/RangeList.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// List of GPU resources with data on guest memory. /// </summary> /// <typeparam name="T">Type of the GPU resource</typeparam> - class RangeList<T> : IEnumerable<T> where T : IRange<T> + class RangeList<T> : IEnumerable<T> where T : IRange { private const int ArrayGrowthSize = 32; |
