diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs index b259dde28..105812ebf 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs @@ -4,6 +4,7 @@ using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; using System; using System.Collections.Generic; +using System.Threading; using static Spv.Specification; namespace Ryujinx.Graphics.Shader.CodeGen.Spirv @@ -19,13 +20,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private const int GeneratorPoolCount = 1; private static readonly ObjectPool _instructionPool; private static readonly ObjectPool _integerPool; - private static readonly object _poolLock; + private static readonly Lock _poolLock = new(); static SpirvGenerator() { _instructionPool = new(() => new SpvInstructionPool(), GeneratorPoolCount); _integerPool = new(() => new SpvLiteralIntegerPool(), GeneratorPoolCount); - _poolLock = new object(); } private const HelperFunctionsMask NeedsInvocationIdMask = HelperFunctionsMask.SwizzleAdd; diff --git a/src/Ryujinx.Graphics.Vulkan/Shader.cs b/src/Ryujinx.Graphics.Vulkan/Shader.cs index f23b78f51..79e2f712a 100644 --- a/src/Ryujinx.Graphics.Vulkan/Shader.cs +++ b/src/Ryujinx.Graphics.Vulkan/Shader.cs @@ -5,6 +5,7 @@ using shaderc; using Silk.NET.Vulkan; using System; using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; namespace Ryujinx.Graphics.Vulkan @@ -13,7 +14,7 @@ namespace Ryujinx.Graphics.Vulkan { // The shaderc.net dependency's Options constructor and dispose are not thread safe. // Take this lock when using them. - private static readonly object _shaderOptionsLock = new(); + private static readonly Lock _shaderOptionsLock = new(); private static readonly nint _ptrMainEntryPointName = Marshal.StringToHGlobalAnsi("main"); diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs index f8ee84842..017365c6f 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs @@ -1,5 +1,6 @@ using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types; using System; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { @@ -23,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger protected BufferQueueConsumer Consumer; - protected readonly object Lock = new(); + protected readonly Lock Lock = new(); private readonly IConsumerListener _listener;