From 6433b1dfd67f4c4f0c4b2e3742dc437a0d1e906e Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 16 Dec 2020 21:09:06 -0800 Subject: service: nvflinger: Improve synchronization for BufferQueue. - Use proper mechanisms for blocking on DequeueBuffer. - Ensure service thread terminates on emulation Shutdown. --- src/core/hle/service/vi/vi.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index ce0272e59..1051000f8 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -544,6 +544,12 @@ private: Settings::values.resolution_factor.GetValue()), static_cast(static_cast(DisplayResolution::UndockedHeight) * Settings::values.resolution_factor.GetValue())}; + + { + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + buffer_queue.Connect(); + } + ctx.WriteBuffer(response.Serialize()); break; } @@ -565,18 +571,15 @@ private: const u32 width{request.data.width}; const u32 height{request.data.height}; - std::optional> result; - - while (!result) { - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); - result = buffer_queue.DequeueBuffer(width, height); - - if (result) { + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + do { + if (auto result = buffer_queue.DequeueBuffer(width, height); result) { // Buffer is available IGBPDequeueBufferResponseParcel response{result->first, *result->second}; ctx.WriteBuffer(response.Serialize()); + break; } - } + } while (buffer_queue.IsConnected()); break; } -- cgit v1.2.3