diff options
| author | 2024-02-19 09:47:19 -0500 | |
|---|---|---|
| committer | 2024-02-19 23:59:35 -0500 | |
| commit | 9f159dd62cbb1a4efe9c5cd724a94caf8c885793 (patch) | |
| tree | 3b419db99ff18b0e7ea58789fd4767d888f3da58 /src/core/hle/service/vi | |
| parent | Import keys from filesystem. (#13056) (diff) | |
| download | yuzu-9f159dd62cbb1a4efe9c5cd724a94caf8c885793.tar.gz yuzu-9f159dd62cbb1a4efe9c5cd724a94caf8c885793.tar.xz yuzu-9f159dd62cbb1a4efe9c5cd724a94caf8c885793.zip | |
nvnflinger/vi: don't recreate buffer queue on open/close
Diffstat (limited to 'src/core/hle/service/vi')
| -rw-r--r-- | src/core/hle/service/vi/container.cpp | 52 | ||||
| -rw-r--r-- | src/core/hle/service/vi/container.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/vi/layer.h | 16 | ||||
| -rw-r--r-- | src/core/hle/service/vi/layer_list.h | 6 |
4 files changed, 38 insertions, 39 deletions
diff --git a/src/core/hle/service/vi/container.cpp b/src/core/hle/service/vi/container.cpp index 310a207f1..9074f4ae0 100644 --- a/src/core/hle/service/vi/container.cpp +++ b/src/core/hle/service/vi/container.cpp | |||
| @@ -43,11 +43,7 @@ void Container::OnTerminate() { | |||
| 43 | 43 | ||
| 44 | m_is_shut_down = true; | 44 | m_is_shut_down = true; |
| 45 | 45 | ||
| 46 | m_layers.ForEachLayer([&](auto& layer) { | 46 | m_layers.ForEachLayer([&](auto& layer) { this->DestroyLayerLocked(layer.GetId()); }); |
| 47 | if (layer.IsOpen()) { | ||
| 48 | this->DestroyBufferQueueLocked(&layer); | ||
| 49 | } | ||
| 50 | }); | ||
| 51 | 47 | ||
| 52 | m_displays.ForEachDisplay( | 48 | m_displays.ForEachDisplay( |
| 53 | [&](auto& display) { m_surface_flinger->RemoveDisplay(display.GetId()); }); | 49 | [&](auto& display) { m_surface_flinger->RemoveDisplay(display.GetId()); }); |
| @@ -161,16 +157,29 @@ Result Container::CreateLayerLocked(u64* out_layer_id, u64 display_id, u64 owner | |||
| 161 | auto* const display = m_displays.GetDisplayById(display_id); | 157 | auto* const display = m_displays.GetDisplayById(display_id); |
| 162 | R_UNLESS(display != nullptr, VI::ResultNotFound); | 158 | R_UNLESS(display != nullptr, VI::ResultNotFound); |
| 163 | 159 | ||
| 164 | auto* const layer = m_layers.CreateLayer(owner_aruid, display); | 160 | s32 consumer_binder_id, producer_binder_id; |
| 161 | m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); | ||
| 162 | |||
| 163 | auto* const layer = | ||
| 164 | m_layers.CreateLayer(owner_aruid, display, consumer_binder_id, producer_binder_id); | ||
| 165 | R_UNLESS(layer != nullptr, VI::ResultNotFound); | 165 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 166 | 166 | ||
| 167 | m_surface_flinger->CreateLayer(consumer_binder_id); | ||
| 168 | |||
| 167 | *out_layer_id = layer->GetId(); | 169 | *out_layer_id = layer->GetId(); |
| 168 | R_SUCCEED(); | 170 | R_SUCCEED(); |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | Result Container::DestroyLayerLocked(u64 layer_id) { | 173 | Result Container::DestroyLayerLocked(u64 layer_id) { |
| 172 | R_SUCCEED_IF(m_layers.DestroyLayer(layer_id)); | 174 | auto* const layer = m_layers.GetLayerById(layer_id); |
| 173 | R_THROW(VI::ResultNotFound); | 175 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 176 | |||
| 177 | m_surface_flinger->DestroyLayer(layer->GetConsumerBinderId()); | ||
| 178 | m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), | ||
| 179 | layer->GetProducerBinderId()); | ||
| 180 | m_layers.DestroyLayer(layer_id); | ||
| 181 | |||
| 182 | R_SUCCEED(); | ||
| 174 | } | 183 | } |
| 175 | 184 | ||
| 176 | Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid) { | 185 | Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid) { |
| @@ -181,7 +190,12 @@ Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 | |||
| 181 | R_UNLESS(!layer->IsOpen(), VI::ResultOperationFailed); | 190 | R_UNLESS(!layer->IsOpen(), VI::ResultOperationFailed); |
| 182 | R_UNLESS(layer->GetOwnerAruid() == aruid, VI::ResultPermissionDenied); | 191 | R_UNLESS(layer->GetOwnerAruid() == aruid, VI::ResultPermissionDenied); |
| 183 | 192 | ||
| 184 | this->CreateBufferQueueLocked(layer); | 193 | layer->Open(); |
| 194 | |||
| 195 | if (auto* display = layer->GetDisplay(); display != nullptr) { | ||
| 196 | m_surface_flinger->AddLayerToDisplayStack(display->GetId(), layer->GetConsumerBinderId()); | ||
| 197 | } | ||
| 198 | |||
| 185 | *out_producer_binder_id = layer->GetProducerBinderId(); | 199 | *out_producer_binder_id = layer->GetProducerBinderId(); |
| 186 | 200 | ||
| 187 | R_SUCCEED(); | 201 | R_SUCCEED(); |
| @@ -192,30 +206,14 @@ Result Container::CloseLayerLocked(u64 layer_id) { | |||
| 192 | R_UNLESS(layer != nullptr, VI::ResultNotFound); | 206 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 193 | R_UNLESS(layer->IsOpen(), VI::ResultOperationFailed); | 207 | R_UNLESS(layer->IsOpen(), VI::ResultOperationFailed); |
| 194 | 208 | ||
| 195 | this->DestroyBufferQueueLocked(layer); | ||
| 196 | |||
| 197 | R_SUCCEED(); | ||
| 198 | } | ||
| 199 | |||
| 200 | void Container::CreateBufferQueueLocked(Layer* layer) { | ||
| 201 | s32 consumer_binder_id, producer_binder_id; | ||
| 202 | m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); | ||
| 203 | layer->Open(consumer_binder_id, producer_binder_id); | ||
| 204 | |||
| 205 | if (auto* display = layer->GetDisplay(); display != nullptr) { | ||
| 206 | m_surface_flinger->AddLayerToDisplayStack(display->GetId(), consumer_binder_id); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | void Container::DestroyBufferQueueLocked(Layer* layer) { | ||
| 211 | if (auto* display = layer->GetDisplay(); display != nullptr) { | 209 | if (auto* display = layer->GetDisplay(); display != nullptr) { |
| 212 | m_surface_flinger->RemoveLayerFromDisplayStack(display->GetId(), | 210 | m_surface_flinger->RemoveLayerFromDisplayStack(display->GetId(), |
| 213 | layer->GetConsumerBinderId()); | 211 | layer->GetConsumerBinderId()); |
| 214 | } | 212 | } |
| 215 | 213 | ||
| 216 | layer->Close(); | 214 | layer->Close(); |
| 217 | m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), | 215 | |
| 218 | layer->GetProducerBinderId()); | 216 | R_SUCCEED(); |
| 219 | } | 217 | } |
| 220 | 218 | ||
| 221 | bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, | 219 | bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, |
diff --git a/src/core/hle/service/vi/container.h b/src/core/hle/service/vi/container.h index cd0d2ca86..5eac4d77d 100644 --- a/src/core/hle/service/vi/container.h +++ b/src/core/hle/service/vi/container.h | |||
| @@ -72,9 +72,6 @@ private: | |||
| 72 | Result OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid); | 72 | Result OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid); |
| 73 | Result CloseLayerLocked(u64 layer_id); | 73 | Result CloseLayerLocked(u64 layer_id); |
| 74 | 74 | ||
| 75 | void CreateBufferQueueLocked(Layer* layer); | ||
| 76 | void DestroyBufferQueueLocked(Layer* layer); | ||
| 77 | |||
| 78 | public: | 75 | public: |
| 79 | bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); | 76 | bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); |
| 80 | 77 | ||
diff --git a/src/core/hle/service/vi/layer.h b/src/core/hle/service/vi/layer.h index b85c8df61..e4c9c9864 100644 --- a/src/core/hle/service/vi/layer.h +++ b/src/core/hle/service/vi/layer.h | |||
| @@ -13,29 +13,31 @@ class Layer { | |||
| 13 | public: | 13 | public: |
| 14 | constexpr Layer() = default; | 14 | constexpr Layer() = default; |
| 15 | 15 | ||
| 16 | void Initialize(u64 id, u64 owner_aruid, Display* display) { | 16 | void Initialize(u64 id, u64 owner_aruid, Display* display, s32 consumer_binder_id, |
| 17 | s32 producer_binder_id) { | ||
| 17 | m_id = id; | 18 | m_id = id; |
| 18 | m_owner_aruid = owner_aruid; | 19 | m_owner_aruid = owner_aruid; |
| 19 | m_display = display; | 20 | m_display = display; |
| 21 | m_consumer_binder_id = consumer_binder_id; | ||
| 22 | m_producer_binder_id = producer_binder_id; | ||
| 20 | m_is_initialized = true; | 23 | m_is_initialized = true; |
| 21 | } | 24 | } |
| 22 | 25 | ||
| 23 | void Finalize() { | 26 | void Finalize() { |
| 24 | m_id = {}; | 27 | m_id = {}; |
| 28 | m_owner_aruid = {}; | ||
| 25 | m_display = {}; | 29 | m_display = {}; |
| 30 | m_consumer_binder_id = {}; | ||
| 31 | m_producer_binder_id = {}; | ||
| 26 | m_is_initialized = {}; | 32 | m_is_initialized = {}; |
| 27 | } | 33 | } |
| 28 | 34 | ||
| 29 | void Open(s32 consumer_binder_id, s32 producer_binder_id) { | 35 | void Open() { |
| 30 | m_consumer_binder_id = consumer_binder_id; | ||
| 31 | m_producer_binder_id = producer_binder_id; | ||
| 32 | m_is_open = true; | 36 | m_is_open = true; |
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | void Close() { | 39 | void Close() { |
| 36 | m_producer_binder_id = {}; | 40 | m_is_open = false; |
| 37 | m_consumer_binder_id = {}; | ||
| 38 | m_is_open = {}; | ||
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | u64 GetId() const { | 43 | u64 GetId() const { |
diff --git a/src/core/hle/service/vi/layer_list.h b/src/core/hle/service/vi/layer_list.h index 1738ede9a..4afca6f40 100644 --- a/src/core/hle/service/vi/layer_list.h +++ b/src/core/hle/service/vi/layer_list.h | |||
| @@ -11,13 +11,15 @@ class LayerList { | |||
| 11 | public: | 11 | public: |
| 12 | constexpr LayerList() = default; | 12 | constexpr LayerList() = default; |
| 13 | 13 | ||
| 14 | Layer* CreateLayer(u64 owner_aruid, Display* display) { | 14 | Layer* CreateLayer(u64 owner_aruid, Display* display, s32 consumer_binder_id, |
| 15 | s32 producer_binder_id) { | ||
| 15 | Layer* const layer = GetFreeLayer(); | 16 | Layer* const layer = GetFreeLayer(); |
| 16 | if (!layer) { | 17 | if (!layer) { |
| 17 | return nullptr; | 18 | return nullptr; |
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | layer->Initialize(++m_next_id, owner_aruid, display); | 21 | layer->Initialize(++m_next_id, owner_aruid, display, consumer_binder_id, |
| 22 | producer_binder_id); | ||
| 21 | return layer; | 23 | return layer; |
| 22 | } | 24 | } |
| 23 | 25 | ||