diff options
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Memory')
| -rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs | 14 | ||||
| -rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs | 8 | ||||
| -rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 6 | ||||
| -rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs | 2 |
4 files changed, 17 insertions, 13 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index e27c14a1..c9286a61 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -140,18 +140,21 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> - /// Gets a sub-range from the buffer, from a start address till the end of the buffer. + /// Gets a sub-range from the buffer, from a start address til a page boundary after the given size. /// </summary> /// <remarks> /// This can be used to bind and use sub-ranges of the buffer on the host API. /// </remarks> /// <param name="address">Start address of the sub-range, must be greater than or equal to the buffer address</param> + /// <param name="size">Size in bytes of the sub-range, must be less than or equal to the buffer size</param> + /// <param name="write">Whether the buffer will be written to by this use</param> /// <returns>The buffer sub-range</returns> - public BufferRange GetRange(ulong address) + public BufferRange GetRangeAligned(ulong address, ulong size, bool write) { + ulong end = ((address + size + MemoryManager.PageMask) & ~MemoryManager.PageMask) - Address; ulong offset = address - Address; - return new BufferRange(Handle, (int)offset, (int)(Size - offset)); + return new BufferRange(Handle, (int)offset, (int)(end - offset), write); } /// <summary> @@ -162,12 +165,13 @@ namespace Ryujinx.Graphics.Gpu.Memory /// </remarks> /// <param name="address">Start address of the sub-range, must be greater than or equal to the buffer address</param> /// <param name="size">Size in bytes of the sub-range, must be less than or equal to the buffer size</param> + /// <param name="write">Whether the buffer will be written to by this use</param> /// <returns>The buffer sub-range</returns> - public BufferRange GetRange(ulong address, ulong size) + public BufferRange GetRange(ulong address, ulong size, bool write) { int offset = (int)(address - Address); - return new BufferRange(Handle, offset, (int)size); + return new BufferRange(Handle, offset, (int)size, write); } /// <summary> diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs index f8f572c6..05cc312c 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs @@ -372,15 +372,15 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> - /// Gets a buffer sub-range starting at a given memory address. + /// Gets a buffer sub-range from a start address til a page boundary after the given size. /// </summary> /// <param name="address">Start address of the memory range</param> /// <param name="size">Size in bytes of the memory range</param> /// <param name="write">Whether the buffer will be written to by this use</param> /// <returns>The buffer sub-range starting at the given memory address</returns> - public BufferRange GetBufferRangeTillEnd(ulong address, ulong size, bool write = false) + public BufferRange GetBufferRangeAligned(ulong address, ulong size, bool write = false) { - return GetBuffer(address, size, write).GetRange(address); + return GetBuffer(address, size, write).GetRangeAligned(address, size, write); } /// <summary> @@ -392,7 +392,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// <returns>The buffer sub-range for the given range</returns> public BufferRange GetBufferRange(ulong address, ulong size, bool write = false) { - return GetBuffer(address, size, write).GetRange(address, size); + return GetBuffer(address, size, write).GetRange(address, size, write); } /// <summary> diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index c656b0f6..bf4cb5d0 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -614,7 +614,7 @@ namespace Ryujinx.Graphics.Gpu.Memory if (_tfInfoBuffer == BufferHandle.Null) { - _tfInfoBuffer = _context.Renderer.CreateBuffer(TfInfoBufferSize); + _tfInfoBuffer = _context.Renderer.CreateBuffer(TfInfoBufferSize, BufferAccess.Stream); } buffers[0] = new BufferAssignment(0, new BufferRange(_tfInfoBuffer, 0, TfInfoBufferSize)); @@ -727,7 +727,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); var range = isStorage - ? bufferCache.GetBufferRangeTillEnd(bounds.Address, bounds.Size, isWrite) + ? bufferCache.GetBufferRangeAligned(bounds.Address, bounds.Size, isWrite) : bufferCache.GetBufferRange(bounds.Address, bounds.Size); ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range); @@ -764,7 +764,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); var range = isStorage - ? bufferCache.GetBufferRangeTillEnd(bounds.Address, bounds.Size, isWrite) + ? bufferCache.GetBufferRangeAligned(bounds.Address, bounds.Size, isWrite) : bufferCache.GetBufferRange(bounds.Address, bounds.Size); ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range); diff --git a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs index 409c7a78..c1e91c54 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs @@ -228,7 +228,7 @@ namespace Ryujinx.Graphics.Gpu.Memory { if (_handle == BufferHandle.Null) { - _handle = _renderer.CreateBuffer(SupportBuffer.RequiredSize); + _handle = _renderer.CreateBuffer(SupportBuffer.RequiredSize, BufferAccess.Stream); _renderer.Pipeline.ClearBuffer(_handle, 0, SupportBuffer.RequiredSize, 0); var range = new BufferRange(_handle, 0, SupportBuffer.RequiredSize); |
