From ad3bc2531ba920d479691e4bd9d9e03373bb28b2 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 9 Dec 2019 18:57:49 -0300 Subject: [PATCH] Ensure a valid shared memory size is used --- Ryujinx.Graphics.Gpu/Engine/Compute.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Gpu/Engine/Compute.cs b/Ryujinx.Graphics.Gpu/Engine/Compute.cs index 61e6b3260..bbf1eeaae 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Compute.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Compute.cs @@ -20,9 +20,12 @@ namespace Ryujinx.Graphics.Gpu.Engine ulong shaderGpuVa = shaderBaseAddress.Pack() + (uint)dispatchParams.ShaderOffset; + // Note: A size of 0 is also invalid, the size must be at least 1. + int sharedMemorySize = Math.Clamp(dispatchParams.SharedMemorySize & 0xffff, 1, _context.Capabilities.MaximumComputeSharedMemorySize); + ComputeShader cs = _shaderCache.GetComputeShader( shaderGpuVa, - dispatchParams.SharedMemorySize & 0xffff, + sharedMemorySize, dispatchParams.UnpackBlockSizeX(), dispatchParams.UnpackBlockSizeY(), dispatchParams.UnpackBlockSizeZ());