diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 30 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.h | 10 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 72c630b4e..d1dbc659b 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -139,11 +139,15 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { | |||
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | const u64 layer_id = next_layer_id++; | 141 | const u64 layer_id = next_layer_id++; |
| 142 | CreateLayerAtId(*display, layer_id); | ||
| 143 | return layer_id; | ||
| 144 | } | ||
| 145 | |||
| 146 | void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { | ||
| 142 | const u32 buffer_queue_id = next_buffer_queue_id++; | 147 | const u32 buffer_queue_id = next_buffer_queue_id++; |
| 143 | buffer_queues.emplace_back( | 148 | buffer_queues.emplace_back( |
| 144 | std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id)); | 149 | std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id)); |
| 145 | display->CreateLayer(layer_id, *buffer_queues.back()); | 150 | display.CreateLayer(layer_id, *buffer_queues.back()); |
| 146 | return layer_id; | ||
| 147 | } | 151 | } |
| 148 | 152 | ||
| 149 | void NVFlinger::CloseLayer(u64 layer_id) { | 153 | void NVFlinger::CloseLayer(u64 layer_id) { |
| @@ -154,9 +158,9 @@ void NVFlinger::CloseLayer(u64 layer_id) { | |||
| 154 | } | 158 | } |
| 155 | } | 159 | } |
| 156 | 160 | ||
| 157 | std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { | 161 | std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) { |
| 158 | const auto lock_guard = Lock(); | 162 | const auto lock_guard = Lock(); |
| 159 | const auto* const layer = FindLayer(display_id, layer_id); | 163 | const auto* const layer = FindOrCreateLayer(display_id, layer_id); |
| 160 | 164 | ||
| 161 | if (layer == nullptr) { | 165 | if (layer == nullptr) { |
| 162 | return std::nullopt; | 166 | return std::nullopt; |
| @@ -232,6 +236,24 @@ const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { | |||
| 232 | return display->FindLayer(layer_id); | 236 | return display->FindLayer(layer_id); |
| 233 | } | 237 | } |
| 234 | 238 | ||
| 239 | VI::Layer* NVFlinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { | ||
| 240 | auto* const display = FindDisplay(display_id); | ||
| 241 | |||
| 242 | if (display == nullptr) { | ||
| 243 | return nullptr; | ||
| 244 | } | ||
| 245 | |||
| 246 | auto* layer = display->FindLayer(layer_id); | ||
| 247 | |||
| 248 | if (layer == nullptr) { | ||
| 249 | LOG_DEBUG(Service, "Layer at id {} not found. Trying to create it.", layer_id); | ||
| 250 | CreateLayerAtId(*display, layer_id); | ||
| 251 | return display->FindLayer(layer_id); | ||
| 252 | } | ||
| 253 | |||
| 254 | return layer; | ||
| 255 | } | ||
| 256 | |||
| 235 | void NVFlinger::Compose() { | 257 | void NVFlinger::Compose() { |
| 236 | for (auto& display : displays) { | 258 | for (auto& display : displays) { |
| 237 | // Trigger vsync for this display at the end of drawing | 259 | // Trigger vsync for this display at the end of drawing |
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index b1cab7db3..d80fd07ef 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -67,7 +67,7 @@ public: | |||
| 67 | /// Finds the buffer queue ID of the specified layer in the specified display. | 67 | /// Finds the buffer queue ID of the specified layer in the specified display. |
| 68 | /// | 68 | /// |
| 69 | /// If an invalid display ID or layer ID is provided, then an empty optional is returned. | 69 | /// If an invalid display ID or layer ID is provided, then an empty optional is returned. |
| 70 | [[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id) const; | 70 | [[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id); |
| 71 | 71 | ||
| 72 | /// Gets the vsync event for the specified display. | 72 | /// Gets the vsync event for the specified display. |
| 73 | /// | 73 | /// |
| @@ -100,6 +100,14 @@ private: | |||
| 100 | /// Finds the layer identified by the specified ID in the desired display. | 100 | /// Finds the layer identified by the specified ID in the desired display. |
| 101 | [[nodiscard]] const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const; | 101 | [[nodiscard]] const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const; |
| 102 | 102 | ||
| 103 | /// Finds the layer identified by the specified ID in the desired display, | ||
| 104 | /// or creates the layer if it is not found. | ||
| 105 | /// To be used when the system expects the specified ID to already exist. | ||
| 106 | [[nodiscard]] VI::Layer* FindOrCreateLayer(u64 display_id, u64 layer_id); | ||
| 107 | |||
| 108 | /// Creates a layer with the specified layer ID in the desired display. | ||
| 109 | void CreateLayerAtId(VI::Display& display, u64 layer_id); | ||
| 110 | |||
| 103 | static void VSyncThread(NVFlinger& nv_flinger); | 111 | static void VSyncThread(NVFlinger& nv_flinger); |
| 104 | 112 | ||
| 105 | void SplitVSync(); | 113 | void SplitVSync(); |