From 04e0472258286421d8e9b31984b0d48876c801f8 Mon Sep 17 00:00:00 2001 From: Marco Carvalho Date: Tue, 3 Dec 2024 13:07:39 -0300 Subject: [PATCH] more Lock --- src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs | 2 +- src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs | 4 ++-- src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs b/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs index 0290987fd..e4b68fa40 100644 --- a/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs +++ b/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Vulkan { bool useBackground = _gd.BackgroundQueue.Handle != 0 && _gd.Vendor != Vendor.Amd; Queue queue = useBackground ? _gd.BackgroundQueue : _gd.Queue; - object queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock; + Lock queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock; lock (queueLock) { diff --git a/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs b/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs index e1fd3fb9d..ed76c6566 100644 --- a/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs +++ b/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Vulkan private readonly Vk _api; private readonly Device _device; private readonly Queue _queue; - private readonly object _queueLock; + private readonly Lock _queueLock; private readonly bool _concurrentFenceWaitUnsupported; private readonly CommandPool _pool; private readonly Thread _owner; @@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Vulkan Vk api, Device device, Queue queue, - object queueLock, + Lock queueLock, uint queueFamilyIndex, bool concurrentFenceWaitUnsupported, bool isLight = false) diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index cc2bc36c2..ad4b18e50 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -11,6 +11,7 @@ using Silk.NET.Vulkan.Extensions.KHR; using System; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Threading; using Format = Ryujinx.Graphics.GAL.Format; using PrimitiveTopology = Ryujinx.Graphics.GAL.PrimitiveTopology; using SamplerCreateInfo = Ryujinx.Graphics.GAL.SamplerCreateInfo; @@ -45,8 +46,8 @@ namespace Ryujinx.Graphics.Vulkan internal uint QueueFamilyIndex { get; private set; } internal Queue Queue { get; private set; } internal Queue BackgroundQueue { get; private set; } - internal object BackgroundQueueLock { get; private set; } - internal object QueueLock { get; private set; } + internal Lock BackgroundQueueLock { get; private set; } + internal Lock QueueLock { get; private set; } internal MemoryAllocator MemoryAllocator { get; private set; } internal HostMemoryAllocator HostMemoryAllocator { get; private set; } @@ -120,7 +121,7 @@ namespace Ryujinx.Graphics.Vulkan } public static VulkanRenderer Create( - string preferredGpuId, + string preferredGpuId, Func getSurface, Func getRequiredExtensions ) => new(Vk.GetApi(), getSurface, getRequiredExtensions, preferredGpuId); @@ -163,7 +164,7 @@ namespace Ryujinx.Graphics.Vulkan { Api.GetDeviceQueue(_device, queueFamilyIndex, 1, out var backgroundQueue); BackgroundQueue = backgroundQueue; - BackgroundQueueLock = new object(); + BackgroundQueueLock = new(); } PhysicalDeviceProperties2 properties2 = new() @@ -496,7 +497,7 @@ namespace Ryujinx.Graphics.Vulkan Api.GetDeviceQueue(_device, queueFamilyIndex, 0, out var queue); Queue = queue; - QueueLock = new object(); + QueueLock = new(); LoadFeatures(maxQueueCount, queueFamilyIndex);