summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-02-19 17:00:03 -0500
committerGravatar Lioncash2019-02-19 18:27:16 -0500
commit8d5d369b54f063606b7c21b2041c4d32154838d6 (patch)
treee33ff3d783d351e6d737e3554d3478630ce44af8 /src
parentMerge pull request #2122 from ReinUsesLisp/vulkan-resource-manager (diff)
downloadyuzu-8d5d369b54f063606b7c21b2041c4d32154838d6.tar.gz
yuzu-8d5d369b54f063606b7c21b2041c4d32154838d6.tar.xz
yuzu-8d5d369b54f063606b7c21b2041c4d32154838d6.zip
service/nvflinger: Relocate definitions of Layer and Display to the vi service
These are more closely related to the vi service as opposed to the intermediary nvflinger. This also places them in their relevant subfolder, as future changes to these will likely result in subclassing to represent various displays and services, as they're done within the service itself on hardware. The reasoning for prefixing the display and layer source files is to avoid potential clashing if two files with the same name are compiled (e.g. if 'display.cpp/.h' or 'layer.cpp/.h' is added to another service at any point), which MSVC will actually warn against. This prevents that case from occurring. This also presently coverts the std::array introduced within f45c25aabacc70861723a7ca1096a677bd987487 back to a std::vector to allow the forward declaration of the Display type. Forward declaring a type within a std::vector is allowed since the introduction of N4510 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4510.html) by Zhihao Yuan.
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp44
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h43
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp22
-rw-r--r--src/core/hle/service/vi/display/vi_display.h28
-rw-r--r--src/core/hle/service/vi/layer/vi_layer.cpp14
-rw-r--r--src/core/hle/service/vi/layer/vi_layer.h25
7 files changed, 123 insertions, 57 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index f61bcd40d..988356c65 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -400,6 +400,10 @@ add_library(core STATIC
400 hle/service/time/time.h 400 hle/service/time/time.h
401 hle/service/usb/usb.cpp 401 hle/service/usb/usb.cpp
402 hle/service/usb/usb.h 402 hle/service/usb/usb.h
403 hle/service/vi/display/vi_display.cpp
404 hle/service/vi/display/vi_display.h
405 hle/service/vi/layer/vi_layer.cpp
406 hle/service/vi/layer/vi_layer.h
403 hle/service/vi/vi.cpp 407 hle/service/vi/vi.cpp
404 hle/service/vi/vi.h 408 hle/service/vi/vi.h
405 hle/service/vi/vi_m.cpp 409 hle/service/vi/vi_m.cpp
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 3babc3f7c..b5d452db1 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -14,11 +14,12 @@
14#include "core/core_timing_util.h" 14#include "core/core_timing_util.h"
15#include "core/hle/kernel/kernel.h" 15#include "core/hle/kernel/kernel.h"
16#include "core/hle/kernel/readable_event.h" 16#include "core/hle/kernel/readable_event.h"
17#include "core/hle/kernel/writable_event.h"
18#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" 17#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
19#include "core/hle/service/nvdrv/nvdrv.h" 18#include "core/hle/service/nvdrv/nvdrv.h"
20#include "core/hle/service/nvflinger/buffer_queue.h" 19#include "core/hle/service/nvflinger/buffer_queue.h"
21#include "core/hle/service/nvflinger/nvflinger.h" 20#include "core/hle/service/nvflinger/nvflinger.h"
21#include "core/hle/service/vi/display/vi_display.h"
22#include "core/hle/service/vi/layer/vi_layer.h"
22#include "core/perf_stats.h" 23#include "core/perf_stats.h"
23#include "video_core/renderer_base.h" 24#include "video_core/renderer_base.h"
24 25
@@ -27,7 +28,9 @@ namespace Service::NVFlinger {
27constexpr std::size_t SCREEN_REFRESH_RATE = 60; 28constexpr std::size_t SCREEN_REFRESH_RATE = 60;
28constexpr u64 frame_ticks = static_cast<u64>(Core::Timing::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE); 29constexpr u64 frame_ticks = static_cast<u64>(Core::Timing::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
29 30
30NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_timing} { 31NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing)
32 : displays{{0, "Default"}, {1, "External"}, {2, "Edid"}, {3, "Internal"}, {4, "Null"}},
33 core_timing{core_timing} {
31 // Schedule the screen composition events 34 // Schedule the screen composition events
32 composition_event = 35 composition_event =
33 core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) { 36 core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) {
@@ -53,7 +56,7 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) {
53 ASSERT(name == "Default"); 56 ASSERT(name == "Default");
54 57
55 const auto itr = std::find_if(displays.begin(), displays.end(), 58 const auto itr = std::find_if(displays.begin(), displays.end(),
56 [&](const Display& display) { return display.name == name; }); 59 [&](const VI::Display& display) { return display.name == name; });
57 if (itr == displays.end()) { 60 if (itr == displays.end()) {
58 return {}; 61 return {};
59 } 62 }
@@ -106,9 +109,10 @@ std::shared_ptr<BufferQueue> NVFlinger::FindBufferQueue(u32 id) const {
106 return *itr; 109 return *itr;
107} 110}
108 111
109Display* NVFlinger::FindDisplay(u64 display_id) { 112VI::Display* NVFlinger::FindDisplay(u64 display_id) {
110 const auto itr = std::find_if(displays.begin(), displays.end(), 113 const auto itr =
111 [&](const Display& display) { return display.id == display_id; }); 114 std::find_if(displays.begin(), displays.end(),
115 [&](const VI::Display& display) { return display.id == display_id; });
112 116
113 if (itr == displays.end()) { 117 if (itr == displays.end()) {
114 return nullptr; 118 return nullptr;
@@ -117,9 +121,10 @@ Display* NVFlinger::FindDisplay(u64 display_id) {
117 return &*itr; 121 return &*itr;
118} 122}
119 123
120const Display* NVFlinger::FindDisplay(u64 display_id) const { 124const VI::Display* NVFlinger::FindDisplay(u64 display_id) const {
121 const auto itr = std::find_if(displays.begin(), displays.end(), 125 const auto itr =
122 [&](const Display& display) { return display.id == display_id; }); 126 std::find_if(displays.begin(), displays.end(),
127 [&](const VI::Display& display) { return display.id == display_id; });
123 128
124 if (itr == displays.end()) { 129 if (itr == displays.end()) {
125 return nullptr; 130 return nullptr;
@@ -128,7 +133,7 @@ const Display* NVFlinger::FindDisplay(u64 display_id) const {
128 return &*itr; 133 return &*itr;
129} 134}
130 135
131Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) { 136VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) {
132 auto* const display = FindDisplay(display_id); 137 auto* const display = FindDisplay(display_id);
133 138
134 if (display == nullptr) { 139 if (display == nullptr) {
@@ -136,7 +141,7 @@ Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) {
136 } 141 }
137 142
138 const auto itr = std::find_if(display->layers.begin(), display->layers.end(), 143 const auto itr = std::find_if(display->layers.begin(), display->layers.end(),
139 [&](const Layer& layer) { return layer.id == layer_id; }); 144 [&](const VI::Layer& layer) { return layer.id == layer_id; });
140 145
141 if (itr == display->layers.end()) { 146 if (itr == display->layers.end()) {
142 return nullptr; 147 return nullptr;
@@ -145,7 +150,7 @@ Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) {
145 return &*itr; 150 return &*itr;
146} 151}
147 152
148const Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { 153const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const {
149 const auto* const display = FindDisplay(display_id); 154 const auto* const display = FindDisplay(display_id);
150 155
151 if (display == nullptr) { 156 if (display == nullptr) {
@@ -153,7 +158,7 @@ const Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const {
153 } 158 }
154 159
155 const auto itr = std::find_if(display->layers.begin(), display->layers.end(), 160 const auto itr = std::find_if(display->layers.begin(), display->layers.end(),
156 [&](const Layer& layer) { return layer.id == layer_id; }); 161 [&](const VI::Layer& layer) { return layer.id == layer_id; });
157 162
158 if (itr == display->layers.end()) { 163 if (itr == display->layers.end()) {
159 return nullptr; 164 return nullptr;
@@ -174,7 +179,7 @@ void NVFlinger::Compose() {
174 // TODO(Subv): Support more than 1 layer. 179 // TODO(Subv): Support more than 1 layer.
175 ASSERT_MSG(display.layers.size() == 1, "Max 1 layer per display is supported"); 180 ASSERT_MSG(display.layers.size() == 1, "Max 1 layer per display is supported");
176 181
177 Layer& layer = display.layers[0]; 182 VI::Layer& layer = display.layers[0];
178 auto& buffer_queue = layer.buffer_queue; 183 auto& buffer_queue = layer.buffer_queue;
179 184
180 // Search for a queued buffer and acquire it 185 // Search for a queued buffer and acquire it
@@ -207,15 +212,4 @@ void NVFlinger::Compose() {
207 } 212 }
208} 213}
209 214
210Layer::Layer(u64 id, std::shared_ptr<BufferQueue> queue) : id(id), buffer_queue(std::move(queue)) {}
211Layer::~Layer() = default;
212
213Display::Display(u64 id, std::string name) : id(id), name(std::move(name)) {
214 auto& kernel = Core::System::GetInstance().Kernel();
215 vsync_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Sticky,
216 fmt::format("Display VSync Event {}", id));
217}
218
219Display::~Display() = default;
220
221} // namespace Service::NVFlinger 215} // namespace Service::NVFlinger
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index 437aa592d..2e000af91 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
8#include <memory> 7#include <memory>
9#include <optional> 8#include <optional>
10#include <string> 9#include <string>
@@ -26,31 +25,17 @@ class WritableEvent;
26 25
27namespace Service::Nvidia { 26namespace Service::Nvidia {
28class Module; 27class Module;
29} 28} // namespace Service::Nvidia
29
30namespace Service::VI {
31struct Display;
32struct Layer;
33} // namespace Service::VI
30 34
31namespace Service::NVFlinger { 35namespace Service::NVFlinger {
32 36
33class BufferQueue; 37class BufferQueue;
34 38
35struct Layer {
36 Layer(u64 id, std::shared_ptr<BufferQueue> queue);
37 ~Layer();
38
39 u64 id;
40 std::shared_ptr<BufferQueue> buffer_queue;
41};
42
43struct Display {
44 Display(u64 id, std::string name);
45 ~Display();
46
47 u64 id;
48 std::string name;
49
50 std::vector<Layer> layers;
51 Kernel::EventPair vsync_event;
52};
53
54class NVFlinger final { 39class NVFlinger final {
55public: 40public:
56 explicit NVFlinger(Core::Timing::CoreTiming& core_timing); 41 explicit NVFlinger(Core::Timing::CoreTiming& core_timing);
@@ -88,26 +73,20 @@ public:
88 73
89private: 74private:
90 /// Finds the display identified by the specified ID. 75 /// Finds the display identified by the specified ID.
91 Display* FindDisplay(u64 display_id); 76 VI::Display* FindDisplay(u64 display_id);
92 77
93 /// Finds the display identified by the specified ID. 78 /// Finds the display identified by the specified ID.
94 const Display* FindDisplay(u64 display_id) const; 79 const VI::Display* FindDisplay(u64 display_id) const;
95 80
96 /// Finds the layer identified by the specified ID in the desired display. 81 /// Finds the layer identified by the specified ID in the desired display.
97 Layer* FindLayer(u64 display_id, u64 layer_id); 82 VI::Layer* FindLayer(u64 display_id, u64 layer_id);
98 83
99 /// Finds the layer identified by the specified ID in the desired display. 84 /// Finds the layer identified by the specified ID in the desired display.
100 const Layer* FindLayer(u64 display_id, u64 layer_id) const; 85 const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const;
101 86
102 std::shared_ptr<Nvidia::Module> nvdrv; 87 std::shared_ptr<Nvidia::Module> nvdrv;
103 88
104 std::array<Display, 5> displays{{ 89 std::vector<VI::Display> displays;
105 {0, "Default"},
106 {1, "External"},
107 {2, "Edid"},
108 {3, "Internal"},
109 {4, "Null"},
110 }};
111 std::vector<std::shared_ptr<BufferQueue>> buffer_queues; 90 std::vector<std::shared_ptr<BufferQueue>> buffer_queues;
112 91
113 /// Id to use for the next layer that is created, this counter is shared among all displays. 92 /// Id to use for the next layer that is created, this counter is shared among all displays.
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
new file mode 100644
index 000000000..a108e468f
--- /dev/null
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -0,0 +1,22 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <fmt/format.h>
6
7#include "core/core.h"
8#include "core/hle/kernel/readable_event.h"
9#include "core/hle/service/vi/display/vi_display.h"
10#include "core/hle/service/vi/layer/vi_layer.h"
11
12namespace Service::VI {
13
14Display::Display(u64 id, std::string name) : id{id}, name{std::move(name)} {
15 auto& kernel = Core::System::GetInstance().Kernel();
16 vsync_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Sticky,
17 fmt::format("Display VSync Event {}", id));
18}
19
20Display::~Display() = default;
21
22} // 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
new file mode 100644
index 000000000..df44db306
--- /dev/null
+++ b/src/core/hle/service/vi/display/vi_display.h
@@ -0,0 +1,28 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <string>
8#include <vector>
9
10#include "common/common_types.h"
11#include "core/hle/kernel/writable_event.h"
12
13namespace Service::VI {
14
15struct Layer;
16
17struct Display {
18 Display(u64 id, std::string name);
19 ~Display();
20
21 u64 id;
22 std::string name;
23
24 std::vector<Layer> layers;
25 Kernel::EventPair vsync_event;
26};
27
28} // namespace Service::VI
diff --git a/src/core/hle/service/vi/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp
new file mode 100644
index 000000000..3a83e5b95
--- /dev/null
+++ b/src/core/hle/service/vi/layer/vi_layer.cpp
@@ -0,0 +1,14 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/hle/service/vi/layer/vi_layer.h"
6
7namespace Service::VI {
8
9Layer::Layer(u64 id, std::shared_ptr<NVFlinger::BufferQueue> queue)
10 : id{id}, buffer_queue{std::move(queue)} {}
11
12Layer::~Layer() = default;
13
14} // namespace Service::VI
diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h
new file mode 100644
index 000000000..df328e09f
--- /dev/null
+++ b/src/core/hle/service/vi/layer/vi_layer.h
@@ -0,0 +1,25 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8
9#include "common/common_types.h"
10
11namespace Service::NVFlinger {
12class BufferQueue;
13}
14
15namespace Service::VI {
16
17struct Layer {
18 Layer(u64 id, std::shared_ptr<NVFlinger::BufferQueue> queue);
19 ~Layer();
20
21 u64 id;
22 std::shared_ptr<NVFlinger::BufferQueue> buffer_queue;
23};
24
25} // namespace Service::VI