Compare shader code using a span instead of individual reads. (#917)
* Compare shader code using a span instead of individual reads. * Add comment for new parameter. * Remove unnecessary Math.Min
This commit is contained in:
parent
796e5d14b4
commit
a0e6647860
3 changed files with 9 additions and 10 deletions
|
@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
{
|
{
|
||||||
ulong processVa = _context.MemoryManager.Translate(gpuVa);
|
ulong processVa = _context.MemoryManager.Translate(gpuVa);
|
||||||
|
|
||||||
ulong size = Math.Min(_context.MemoryManager.GetSubSize(gpuVa), maxSize);
|
ulong size = _context.MemoryManager.GetSubSize(gpuVa, maxSize);
|
||||||
|
|
||||||
return _context.PhysicalMemory.GetSpan(processVa, size);
|
return _context.PhysicalMemory.GetSpan(processVa, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,14 +237,19 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// Gets the number of mapped or reserved pages on a given region.
|
/// Gets the number of mapped or reserved pages on a given region.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gpuVa">Start GPU virtual address of the region</param>
|
/// <param name="gpuVa">Start GPU virtual address of the region</param>
|
||||||
|
/// <param name="maxSize">Maximum size of the data</param>
|
||||||
/// <returns>Mapped size in bytes of the specified region</returns>
|
/// <returns>Mapped size in bytes of the specified region</returns>
|
||||||
internal ulong GetSubSize(ulong gpuVa)
|
internal ulong GetSubSize(ulong gpuVa, ulong maxSize)
|
||||||
{
|
{
|
||||||
ulong size = 0;
|
ulong size = 0;
|
||||||
|
|
||||||
while (GetPte(gpuVa + size) != PteUnmapped)
|
while (GetPte(gpuVa + size) != PteUnmapped)
|
||||||
{
|
{
|
||||||
size += PageSize;
|
size += PageSize;
|
||||||
|
if (size >= maxSize)
|
||||||
|
{
|
||||||
|
return maxSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -235,15 +235,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < shader.Code.Length; index++)
|
ReadOnlySpan<byte> memoryCode = _context.MemoryAccessor.GetSpan(gpuVa, (ulong)shader.Code.Length * 4);
|
||||||
{
|
|
||||||
if (_context.MemoryAccessor.ReadInt32(gpuVa + (ulong)index * 4) != shader.Code[index])
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return !MemoryMarshal.Cast<byte, int>(memoryCode).SequenceEqual(shader.Code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Reference in a new issue