summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp6
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h3
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp27
-rw-r--r--src/core/hle/service/vi/display/vi_display.h9
-rw-r--r--src/core/hle/service/vi/vi.cpp14
5 files changed, 48 insertions, 11 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 9810d2c64..62752e419 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -88,6 +88,12 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) {
88 return layer_id; 88 return layer_id;
89} 89}
90 90
91void NVFlinger::CloseLayer(u64 layer_id) {
92 for (auto& display : displays) {
93 display.CloseLayer(layer_id);
94 }
95}
96
91std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { 97std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const {
92 const auto* const layer = FindLayer(display_id, layer_id); 98 const auto* const layer = FindLayer(display_id, layer_id);
93 99
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index e3cc14bdc..57a21f33b 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -54,6 +54,9 @@ public:
54 /// If an invalid display ID is specified, then an empty optional is returned. 54 /// If an invalid display ID is specified, then an empty optional is returned.
55 std::optional<u64> CreateLayer(u64 display_id); 55 std::optional<u64> CreateLayer(u64 display_id);
56 56
57 /// Closes a layer on all displays for the given layer ID.
58 void CloseLayer(u64 layer_id);
59
57 /// Finds the buffer queue ID of the specified layer in the specified display. 60 /// Finds the buffer queue ID of the specified layer in the specified display.
58 /// 61 ///
59 /// If an invalid display ID or layer ID is provided, then an empty optional is returned. 62 /// If an invalid display ID or layer ID is provided, then an empty optional is returned.
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index cd18c1610..5a202ac81 100644
--- a/src/core/hle/service/vi/display/vi_display.cpp
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -24,11 +24,11 @@ Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{
24Display::~Display() = default; 24Display::~Display() = default;
25 25
26Layer& Display::GetLayer(std::size_t index) { 26Layer& Display::GetLayer(std::size_t index) {
27 return layers.at(index); 27 return *layers.at(index);
28} 28}
29 29
30const Layer& Display::GetLayer(std::size_t index) const { 30const Layer& Display::GetLayer(std::size_t index) const {
31 return layers.at(index); 31 return *layers.at(index);
32} 32}
33 33
34std::shared_ptr<Kernel::ReadableEvent> Display::GetVSyncEvent() const { 34std::shared_ptr<Kernel::ReadableEvent> Display::GetVSyncEvent() const {
@@ -43,29 +43,38 @@ void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) {
43 // TODO(Subv): Support more than 1 layer. 43 // TODO(Subv): Support more than 1 layer.
44 ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); 44 ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment");
45 45
46 layers.emplace_back(id, buffer_queue); 46 layers.emplace_back(std::make_shared<Layer>(id, buffer_queue));
47}
48
49void Display::CloseLayer(u64 id) {
50 layers.erase(
51 std::remove_if(layers.begin(), layers.end(),
52 [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }),
53 layers.end());
47} 54}
48 55
49Layer* Display::FindLayer(u64 id) { 56Layer* Display::FindLayer(u64 id) {
50 const auto itr = std::find_if(layers.begin(), layers.end(), 57 const auto itr =
51 [id](const VI::Layer& layer) { return layer.GetID() == id; }); 58 std::find_if(layers.begin(), layers.end(),
59 [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; });
52 60
53 if (itr == layers.end()) { 61 if (itr == layers.end()) {
54 return nullptr; 62 return nullptr;
55 } 63 }
56 64
57 return &*itr; 65 return itr->get();
58} 66}
59 67
60const Layer* Display::FindLayer(u64 id) const { 68const Layer* Display::FindLayer(u64 id) const {
61 const auto itr = std::find_if(layers.begin(), layers.end(), 69 const auto itr =
62 [id](const VI::Layer& layer) { return layer.GetID() == id; }); 70 std::find_if(layers.begin(), layers.end(),
71 [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; });
63 72
64 if (itr == layers.end()) { 73 if (itr == layers.end()) {
65 return nullptr; 74 return nullptr;
66 } 75 }
67 76
68 return &*itr; 77 return itr->get();
69} 78}
70 79
71} // namespace Service::VI 80} // namespace Service::VI
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h
index 8bb966a85..a3855d8cd 100644
--- a/src/core/hle/service/vi/display/vi_display.h
+++ b/src/core/hle/service/vi/display/vi_display.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
7#include <string> 8#include <string>
8#include <vector> 9#include <vector>
9 10
@@ -69,6 +70,12 @@ public:
69 /// 70 ///
70 void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue); 71 void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue);
71 72
73 /// Closes and removes a layer from this display with the given ID.
74 ///
75 /// @param id The ID assigned to the layer to close.
76 ///
77 void CloseLayer(u64 id);
78
72 /// Attempts to find a layer with the given ID. 79 /// Attempts to find a layer with the given ID.
73 /// 80 ///
74 /// @param id The layer ID. 81 /// @param id The layer ID.
@@ -91,7 +98,7 @@ private:
91 u64 id; 98 u64 id;
92 std::string name; 99 std::string name;
93 100
94 std::vector<Layer> layers; 101 std::vector<std::shared_ptr<Layer>> layers;
95 Kernel::EventPair vsync_event; 102 Kernel::EventPair vsync_event;
96}; 103};
97 104
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 651c89dc0..519da74e0 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -1066,6 +1066,18 @@ private:
1066 rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize())); 1066 rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize()));
1067 } 1067 }
1068 1068
1069 void CloseLayer(Kernel::HLERequestContext& ctx) {
1070 IPC::RequestParser rp{ctx};
1071 const auto layer_id{rp.Pop<u64>()};
1072
1073 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id);
1074
1075 nv_flinger->CloseLayer(layer_id);
1076
1077 IPC::ResponseBuilder rb{ctx, 2};
1078 rb.Push(RESULT_SUCCESS);
1079 }
1080
1069 void CreateStrayLayer(Kernel::HLERequestContext& ctx) { 1081 void CreateStrayLayer(Kernel::HLERequestContext& ctx) {
1070 IPC::RequestParser rp{ctx}; 1082 IPC::RequestParser rp{ctx};
1071 const u32 flags = rp.Pop<u32>(); 1083 const u32 flags = rp.Pop<u32>();
@@ -1178,7 +1190,7 @@ IApplicationDisplayService::IApplicationDisplayService(
1178 {1101, &IApplicationDisplayService::SetDisplayEnabled, "SetDisplayEnabled"}, 1190 {1101, &IApplicationDisplayService::SetDisplayEnabled, "SetDisplayEnabled"},
1179 {1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"}, 1191 {1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"},
1180 {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"}, 1192 {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"},
1181 {2021, nullptr, "CloseLayer"}, 1193 {2021, &IApplicationDisplayService::CloseLayer, "CloseLayer"},
1182 {2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"}, 1194 {2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"},
1183 {2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"}, 1195 {2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"},
1184 {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"}, 1196 {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"},