From a0e6647860b689cd2c3d865e6b235b12ec96b89a Mon Sep 17 00:00:00 2001 From: riperiperi Date: Mon, 3 Feb 2020 19:11:22 +0000 Subject: 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 --- Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Shader') diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 8aa9b1c7..fc4bf778 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -235,15 +235,9 @@ namespace Ryujinx.Graphics.Gpu.Shader return false; } - for (int index = 0; index < shader.Code.Length; index++) - { - if (_context.MemoryAccessor.ReadInt32(gpuVa + (ulong)index * 4) != shader.Code[index]) - { - return true; - } - } + ReadOnlySpan memoryCode = _context.MemoryAccessor.GetSpan(gpuVa, (ulong)shader.Code.Length * 4); - return false; + return !MemoryMarshal.Cast(memoryCode).SequenceEqual(shader.Code); } /// -- cgit v1.2.3