summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvflinger
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-10-30 01:11:26 +0200
committerGitHub <noreply@github.com>2022-10-30 01:11:26 +0200
commitc4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb (patch)
tree0653781de68f88b7910b78e5c3d893b06e9dc37d /src/core/hle/service/nvflinger
parentMerge pull request #9140 from vonchenplus/darw_index_bufferx_first_error (diff)
parentnvnflinger: release queued handles immediately on disconnection (diff)
downloadyuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.tar
yuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.tar.gz
yuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.tar.bz2
yuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.tar.lz
yuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.tar.xz
yuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.tar.zst
yuzu-c4d91488d9e7d1aadfadb6ef8e27fa4f1896a5cb.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue_producer.cpp7
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp13
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h5
3 files changed, 25 insertions, 0 deletions
diff --git a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp
index 77ddbb6ef..41ba44b21 100644
--- a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp
@@ -742,6 +742,13 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) {
return Status::NoError;
}
+ // HACK: We are not Android. Remove handle for items in queue, and clear queue.
+ // Allows synchronous destruction of nvmap handles.
+ for (auto& item : core->queue) {
+ nvmap.FreeHandle(item.graphic_buffer->BufferId(), true);
+ }
+ core->queue.clear();
+
switch (api) {
case NativeWindowApi::Egl:
case NativeWindowApi::Cpu:
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index dad93b38e..c3af12c90 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -138,6 +138,19 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) {
return itr->GetID();
}
+bool NVFlinger::CloseDisplay(u64 display_id) {
+ const auto lock_guard = Lock();
+ auto* const display = FindDisplay(display_id);
+
+ if (display == nullptr) {
+ return false;
+ }
+
+ display->Reset();
+
+ return true;
+}
+
std::optional<u64> NVFlinger::CreateLayer(u64 display_id) {
const auto lock_guard = Lock();
auto* const display = FindDisplay(display_id);
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index b8191c595..460bef976 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -58,6 +58,11 @@ public:
/// If an invalid display name is provided, then an empty optional is returned.
[[nodiscard]] std::optional<u64> OpenDisplay(std::string_view name);
+ /// Closes the specified display by its ID.
+ ///
+ /// Returns false if an invalid display ID is provided.
+ [[nodiscard]] bool CloseDisplay(u64 display_id);
+
/// Creates a layer on the specified display and returns the layer ID.
///
/// If an invalid display ID is specified, then an empty optional is returned.