aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/Buffer.cs15
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/BufferManager.cs23
2 files changed, 36 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index 7127871a..cdd61b6d 100644
--- a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -89,6 +89,21 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
+ /// Gets a sub-range from the buffer, from a start address till the end of the buffer.
+ /// </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>
+ /// <returns>The buffer sub-range</returns>
+ public BufferRange GetRange(ulong address)
+ {
+ ulong offset = address - Address;
+
+ return new BufferRange(Handle, (int)offset, (int)(Size - offset));
+ }
+
+ /// <summary>
/// Gets a sub-range from the buffer.
/// </summary>
/// <remarks>
diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
index cdcc5a37..08d52faa 100644
--- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
@@ -591,7 +591,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (bounds.Address != 0)
{
- sRanges[bindingInfo.Binding] = GetBufferRange(bounds.Address, bounds.Size, bounds.Flags.HasFlag(BufferUsageFlags.Write));
+ // The storage buffer size is not reliable (it might be lower than the actual size),
+ // so we bind the entire buffer to allow otherwise out of range accesses to work.
+ sRanges[bindingInfo.Binding] = GetBufferRangeTillEnd(
+ bounds.Address,
+ bounds.Size,
+ bounds.Flags.HasFlag(BufferUsageFlags.Write));
}
}
@@ -764,7 +769,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (bounds.Address != 0)
{
- ranges[bindingInfo.Binding] = GetBufferRange(bounds.Address, bounds.Size, bounds.Flags.HasFlag(BufferUsageFlags.Write));
+ ranges[bindingInfo.Binding] = isStorage
+ ? GetBufferRangeTillEnd(bounds.Address, bounds.Size, bounds.Flags.HasFlag(BufferUsageFlags.Write))
+ : GetBufferRange(bounds.Address, bounds.Size, bounds.Flags.HasFlag(BufferUsageFlags.Write));
}
}
}
@@ -896,6 +903,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
+ /// Gets a buffer sub-range starting at a given memory address.
+ /// </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>
+ private BufferRange GetBufferRangeTillEnd(ulong address, ulong size, bool write = false)
+ {
+ return GetBuffer(address, size, write).GetRange(address);
+ }
+
+ /// <summary>
/// Gets a buffer sub-range for a given memory range.
/// </summary>
/// <param name="address">Start address of the memory range</param>