From 09341dc11d88de39b2b4fb990ec730b4d57f8b0a Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 29 Aug 2020 16:42:34 -0300 Subject: [PATCH] Fix off by one error in pages count calculation on GPU pool (#1511) --- Ryujinx.Graphics.Gpu/Image/Pool.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Gpu/Image/Pool.cs b/Ryujinx.Graphics.Gpu/Image/Pool.cs index 8796894c4..0abf68243 100644 --- a/Ryujinx.Graphics.Gpu/Image/Pool.cs +++ b/Ryujinx.Graphics.Gpu/Image/Pool.cs @@ -1,3 +1,4 @@ +using Ryujinx.Common; using Ryujinx.Graphics.Gpu.Memory; using System; @@ -49,7 +50,11 @@ namespace Ryujinx.Graphics.Gpu.Image Address = address; Size = size; - _modifiedRanges = new (ulong, ulong)[size / PhysicalMemory.PageSize]; + ulong endAddress = BitUtils.AlignUp(Address + Size, PhysicalMemory.PageSize); + + ulong pagesCount = (endAddress - BitUtils.AlignDown(Address, PhysicalMemory.PageSize)) / PhysicalMemory.PageSize; + + _modifiedRanges = new (ulong, ulong)[pagesCount]; } ///