From 1f186f34a29da8c4e39e3ad25fff1e4a39b33e85 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 12 Oct 2020 17:35:34 -0700 Subject: hle: service: vi: Implement BufferQueue::CancelBuffer. - This is used by Super Mario 3D All-Stars. --- src/core/hle/service/nvflinger/buffer_queue.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/hle/service/nvflinger/buffer_queue.h') diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 8a837e5aa..e7517c7e1 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -95,6 +95,7 @@ public: void QueueBuffer(u32 slot, BufferTransformFlags transform, const Common::Rectangle& crop_rect, u32 swap_interval, Service::Nvidia::MultiFence& multi_fence); + void CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& multi_fence); std::optional> AcquireBuffer(); void ReleaseBuffer(u32 slot); void Disconnect(); -- cgit v1.2.3 From 8cb683f3b9a419c2472ead6750621c671a5becff Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Thu, 17 Dec 2020 14:22:46 -0500 Subject: Overwrite slots instead of queuing them, add disconnect signal Fix for Katana Zero and Yoshi's Crafted World --- src/core/hle/service/nvflinger/buffer_queue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service/nvflinger/buffer_queue.h') diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index e7517c7e1..e610923cb 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -21,6 +21,7 @@ class KernelCore; namespace Service::NVFlinger { +constexpr u32 buffer_slots = 0x40; struct IGBPBuffer { u32_le magic; u32_le width; @@ -114,7 +115,7 @@ private: u64 layer_id; std::list free_buffers; - std::vector queue; + std::array buffers; std::list queue_sequence; Kernel::EventPair buffer_wait_event; }; -- cgit v1.2.3 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/nvflinger/buffer_queue.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/nvflinger/buffer_queue.h') diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index e610923cb..a2f60d9eb 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -4,7 +4,9 @@ #pragma once +#include #include +#include #include #include @@ -99,6 +101,7 @@ public: void CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& multi_fence); std::optional> AcquireBuffer(); void ReleaseBuffer(u32 slot); + void Connect(); void Disconnect(); u32 Query(QueryType type); @@ -106,18 +109,28 @@ public: return id; } + bool IsConnected() const { + return is_connect; + } + std::shared_ptr GetWritableBufferWaitEvent() const; std::shared_ptr GetBufferWaitEvent() const; private: - u32 id; - u64 layer_id; + BufferQueue(const BufferQueue&) = delete; + + u32 id{}; + u64 layer_id{}; + std::atomic_bool is_connect{}; std::list free_buffers; std::array buffers; std::list queue_sequence; Kernel::EventPair buffer_wait_event; + + std::mutex queue_mutex; + std::condition_variable condition; }; } // namespace Service::NVFlinger -- cgit v1.2.3 From 6b354ccaee6988b91a97b1b70b4d84bd4d244cb1 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Mon, 4 Jan 2021 01:36:41 -0500 Subject: buffer_queue: Protect queue_sequence list access with a mutex fixes a data race as this is an unprotected variable manipulated by multiple threads --- src/core/hle/service/nvflinger/buffer_queue.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/nvflinger/buffer_queue.h') diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index a2f60d9eb..ad7469277 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -129,8 +129,10 @@ private: std::list queue_sequence; Kernel::EventPair buffer_wait_event; - std::mutex queue_mutex; - std::condition_variable condition; + std::mutex free_buffers_mutex; + std::condition_variable free_buffers_condition; + + std::mutex queue_sequence_mutex; }; } // namespace Service::NVFlinger -- cgit v1.2.3