0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-23 12:45:50 +00:00

More code cleanup

This commit is contained in:
gdkchan 2019-12-31 19:37:00 -03:00 committed by Thog
parent 9bfb373bdf
commit 6e092c0558
4 changed files with 13 additions and 16 deletions

View file

@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary> /// <summary>
/// Represents a cached GPU texture. /// Represents a cached GPU texture.
/// </summary> /// </summary>
class Texture : IRange<Texture>, IDisposable class Texture : IRange, IDisposable
{ {
private GpuContext _context; private GpuContext _context;

View file

@ -6,16 +6,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <summary> /// <summary>
/// Buffer, used to store vertex and index data, uniform and storage buffers, and others. /// Buffer, used to store vertex and index data, uniform and storage buffers, and others.
/// </summary> /// </summary>
class Buffer : IRange<Buffer>, IDisposable class Buffer : IRange, IDisposable
{ {
private GpuContext _context; private readonly GpuContext _context;
private IBuffer _buffer;
/// <summary> /// <summary>
/// Host buffer object. /// Host buffer object.
/// </summary> /// </summary>
public IBuffer HostBuffer => _buffer; public IBuffer HostBuffer { get; }
/// <summary> /// <summary>
/// Start address of the buffer in guest memory. /// Start address of the buffer in guest memory.
@ -46,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
Address = address; Address = address;
Size = size; Size = size;
_buffer = context.Renderer.CreateBuffer((int)size); HostBuffer = context.Renderer.CreateBuffer((int)size);
_sequenceNumbers = new int[size / MemoryManager.PageSize]; _sequenceNumbers = new int[size / MemoryManager.PageSize];
@ -64,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
int offset = (int)(address - Address); int offset = (int)(address - Address);
return new BufferRange(_buffer, offset, (int)size); return new BufferRange(HostBuffer, offset, (int)size);
} }
/// <summary> /// <summary>
@ -121,7 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int offset = (int)(mAddress - Address); 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> /// <param name="dstOffset">The offset of the destination buffer to copy into</param>
public void CopyTo(Buffer destination, int dstOffset) public void CopyTo(Buffer destination, int dstOffset)
{ {
_buffer.CopyTo(destination._buffer, 0, dstOffset, (int)Size); HostBuffer.CopyTo(destination.HostBuffer, 0, dstOffset, (int)Size);
} }
/// <summary> /// <summary>
@ -145,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
int offset = (int)(address - Address); int offset = (int)(address - Address);
byte[] data = _buffer.GetData(offset, (int)size); byte[] data = HostBuffer.GetData(offset, (int)size);
_context.PhysicalMemory.Write(address, data); _context.PhysicalMemory.Write(address, data);
} }
@ -155,7 +153,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary> /// </summary>
public void Invalidate() public void Invalidate()
{ {
_buffer.SetData(0, _context.PhysicalMemory.Read(Address, Size)); HostBuffer.SetData(0, _context.PhysicalMemory.Read(Address, Size));
} }
/// <summary> /// <summary>
@ -163,7 +161,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
_buffer.Dispose(); HostBuffer.Dispose();
} }
} }
} }

View file

@ -3,8 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <summary> /// <summary>
/// Range of memory. /// Range of memory.
/// </summary> /// </summary>
/// <typeparam name="T">GPU resource type</typeparam> interface IRange
interface IRange<T>
{ {
ulong Address { get; } ulong Address { get; }
ulong Size { get; } ulong Size { get; }

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// List of GPU resources with data on guest memory. /// List of GPU resources with data on guest memory.
/// </summary> /// </summary>
/// <typeparam name="T">Type of the GPU resource</typeparam> /// <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; private const int ArrayGrowthSize = 32;