summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp32
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h9
2 files changed, 20 insertions, 21 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 6a613aeab..6db2cce41 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -5,7 +5,6 @@
5#include <algorithm> 5#include <algorithm>
6#include <optional> 6#include <optional>
7 7
8#include "common/alignment.h"
9#include "common/assert.h" 8#include "common/assert.h"
10#include "common/logging/log.h" 9#include "common/logging/log.h"
11#include "common/microprofile.h" 10#include "common/microprofile.h"
@@ -22,7 +21,6 @@
22#include "core/hle/service/nvflinger/nvflinger.h" 21#include "core/hle/service/nvflinger/nvflinger.h"
23#include "core/perf_stats.h" 22#include "core/perf_stats.h"
24#include "video_core/renderer_base.h" 23#include "video_core/renderer_base.h"
25#include "video_core/video_core.h"
26 24
27namespace Service::NVFlinger { 25namespace Service::NVFlinger {
28 26
@@ -30,12 +28,6 @@ constexpr std::size_t SCREEN_REFRESH_RATE = 60;
30constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE); 28constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
31 29
32NVFlinger::NVFlinger() { 30NVFlinger::NVFlinger() {
33 // Add the different displays to the list of displays.
34 displays.emplace_back(0, "Default");
35 displays.emplace_back(1, "External");
36 displays.emplace_back(2, "Edid");
37 displays.emplace_back(3, "Internal");
38
39 // Schedule the screen composition events 31 // Schedule the screen composition events
40 composition_event = 32 composition_event =
41 CoreTiming::RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) { 33 CoreTiming::RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) {
@@ -55,13 +47,13 @@ void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
55} 47}
56 48
57u64 NVFlinger::OpenDisplay(std::string_view name) { 49u64 NVFlinger::OpenDisplay(std::string_view name) {
58 LOG_WARNING(Service, "Opening display {}", name); 50 LOG_DEBUG(Service, "Opening \"{}\" display", name);
59 51
60 // TODO(Subv): Currently we only support the Default display. 52 // TODO(Subv): Currently we only support the Default display.
61 ASSERT(name == "Default"); 53 ASSERT(name == "Default");
62 54
63 auto itr = std::find_if(displays.begin(), displays.end(), 55 const auto itr = std::find_if(displays.begin(), displays.end(),
64 [&](const Display& display) { return display.name == name; }); 56 [&](const Display& display) { return display.name == name; });
65 57
66 ASSERT(itr != displays.end()); 58 ASSERT(itr != displays.end());
67 59
@@ -73,8 +65,8 @@ u64 NVFlinger::CreateLayer(u64 display_id) {
73 65
74 ASSERT_MSG(display.layers.empty(), "Only one layer is supported per display at the moment"); 66 ASSERT_MSG(display.layers.empty(), "Only one layer is supported per display at the moment");
75 67
76 u64 layer_id = next_layer_id++; 68 const u64 layer_id = next_layer_id++;
77 u32 buffer_queue_id = next_buffer_queue_id++; 69 const u32 buffer_queue_id = next_buffer_queue_id++;
78 auto buffer_queue = std::make_shared<BufferQueue>(buffer_queue_id, layer_id); 70 auto buffer_queue = std::make_shared<BufferQueue>(buffer_queue_id, layer_id);
79 display.layers.emplace_back(layer_id, buffer_queue); 71 display.layers.emplace_back(layer_id, buffer_queue);
80 buffer_queues.emplace_back(std::move(buffer_queue)); 72 buffer_queues.emplace_back(std::move(buffer_queue));
@@ -91,16 +83,16 @@ Kernel::SharedPtr<Kernel::ReadableEvent> NVFlinger::GetVsyncEvent(u64 display_id
91} 83}
92 84
93std::shared_ptr<BufferQueue> NVFlinger::GetBufferQueue(u32 id) const { 85std::shared_ptr<BufferQueue> NVFlinger::GetBufferQueue(u32 id) const {
94 auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), 86 const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(),
95 [&](const auto& queue) { return queue->GetId() == id; }); 87 [&](const auto& queue) { return queue->GetId() == id; });
96 88
97 ASSERT(itr != buffer_queues.end()); 89 ASSERT(itr != buffer_queues.end());
98 return *itr; 90 return *itr;
99} 91}
100 92
101Display& NVFlinger::GetDisplay(u64 display_id) { 93Display& NVFlinger::GetDisplay(u64 display_id) {
102 auto itr = std::find_if(displays.begin(), displays.end(), 94 const auto itr = std::find_if(displays.begin(), displays.end(),
103 [&](const Display& display) { return display.id == display_id; }); 95 [&](const Display& display) { return display.id == display_id; });
104 96
105 ASSERT(itr != displays.end()); 97 ASSERT(itr != displays.end());
106 return *itr; 98 return *itr;
@@ -109,8 +101,8 @@ Display& NVFlinger::GetDisplay(u64 display_id) {
109Layer& NVFlinger::GetLayer(u64 display_id, u64 layer_id) { 101Layer& NVFlinger::GetLayer(u64 display_id, u64 layer_id) {
110 auto& display = GetDisplay(display_id); 102 auto& display = GetDisplay(display_id);
111 103
112 auto itr = std::find_if(display.layers.begin(), display.layers.end(), 104 const auto itr = std::find_if(display.layers.begin(), display.layers.end(),
113 [&](const Layer& layer) { return layer.id == layer_id; }); 105 [&](const Layer& layer) { return layer.id == layer_id; });
114 106
115 ASSERT(itr != display.layers.end()); 107 ASSERT(itr != display.layers.end());
116 return *itr; 108 return *itr;
@@ -145,7 +137,7 @@ void NVFlinger::Compose() {
145 continue; 137 continue;
146 } 138 }
147 139
148 auto& igbp_buffer = buffer->get().igbp_buffer; 140 const auto& igbp_buffer = buffer->get().igbp_buffer;
149 141
150 // Now send the buffer to the GPU for drawing. 142 // Now send the buffer to the GPU for drawing.
151 // TODO(Subv): Support more than just disp0. The display device selection is probably based 143 // TODO(Subv): Support more than just disp0. The display device selection is probably based
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index 9abba555b..8f9a0a7f8 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <memory> 8#include <memory>
8#include <string> 9#include <string>
9#include <string_view> 10#include <string_view>
@@ -84,7 +85,13 @@ private:
84 85
85 std::shared_ptr<Nvidia::Module> nvdrv; 86 std::shared_ptr<Nvidia::Module> nvdrv;
86 87
87 std::vector<Display> displays; 88 std::array<Display, 5> displays{{
89 {0, "Default"},
90 {1, "External"},
91 {2, "Edid"},
92 {3, "Internal"},
93 {4, "Null"},
94 }};
88 std::vector<std::shared_ptr<BufferQueue>> buffer_queues; 95 std::vector<std::shared_ptr<BufferQueue>> buffer_queues;
89 96
90 /// Id to use for the next layer that is created, this counter is shared among all displays. 97 /// Id to use for the next layer that is created, this counter is shared among all displays.