Memory Changes part 2

* Slightly refactors RangeLists from the last Memory Changes MR, which fixes issue 61.

* Convert as many const size array iterators to span iterators as possible. When iterating over a const size array, every iteration created a Span, now only the first iteration does in most places.

* Now using object pooling for a few object types that were rapidly deleted and recreated.

* Converted a few flag checks to binary operations to save memory allocations.
This commit is contained in:
LotP
2025-09-12 21:24:19 -05:00
committed by KeatonTheBot
parent ff0daa9f35
commit 3deddbd491
89 changed files with 2121 additions and 1154 deletions
@@ -92,20 +92,24 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
if (pictureInfo.ScalingMatrixPresent)
{
Span<Array16<byte>> scalingLists4x4Span = pictureInfo.ScalingLists4x4.AsSpan();
for (int index = 0; index < 6; index++)
{
writer.WriteBit(true);
WriteScalingList(ref writer, pictureInfo.ScalingLists4x4[index]);
WriteScalingList(ref writer, scalingLists4x4Span[index]);
}
if (pictureInfo.Transform8x8ModeFlag)
{
Span<Array64<byte>> scalingLists8x8Span = pictureInfo.ScalingLists8x8.AsSpan();
for (int index = 0; index < 2; index++)
{
writer.WriteBit(true);
WriteScalingList(ref writer, pictureInfo.ScalingLists8x8[index]);
WriteScalingList(ref writer, scalingLists8x8Span[index]);
}
}
}
@@ -144,9 +148,11 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
int lastScale = 8;
for (int index = 0; index < list.Length; index++)
Span<byte> listSpan = list.AsSpan();
for (int index = 0; index < listSpan.Length; index++)
{
byte value = list[scan[index]];
byte value = listSpan[scan[index]];
int deltaScale = value - lastScale;