diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-02-21 00:30:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-21 00:30:47 +0100 |
commit | ea4a96b45e829364fcfd35b5463823817b1af336 (patch) | |
tree | cbbd0ef060e002e573b7dd25db610165633404b6 /src/core/hle/service/vi | |
parent | Import keys from filesystem. (#13056) (diff) | |
parent | vi: ignore shared buffer destruction failure on termination (diff) | |
download | yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.tar yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.tar.gz yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.tar.bz2 yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.tar.lz yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.tar.xz yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.tar.zst yuzu-ea4a96b45e829364fcfd35b5463823817b1af336.zip |
Diffstat (limited to '')
-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 | ||||
-rw-r--r-- | src/core/hle/service/vi/shared_buffer_manager.cpp | 10 |
5 files changed, 39 insertions, 48 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() { m_is_shut_down = true; - m_layers.ForEachLayer([&](auto& layer) { - if (layer.IsOpen()) { - this->DestroyBufferQueueLocked(&layer); - } - }); + m_layers.ForEachLayer([&](auto& layer) { this->DestroyLayerLocked(layer.GetId()); }); m_displays.ForEachDisplay( [&](auto& display) { m_surface_flinger->RemoveDisplay(display.GetId()); }); @@ -161,16 +157,29 @@ Result Container::CreateLayerLocked(u64* out_layer_id, u64 display_id, u64 owner auto* const display = m_displays.GetDisplayById(display_id); R_UNLESS(display != nullptr, VI::ResultNotFound); - auto* const layer = m_layers.CreateLayer(owner_aruid, display); + s32 consumer_binder_id, producer_binder_id; + m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); + + auto* const layer = + m_layers.CreateLayer(owner_aruid, display, consumer_binder_id, producer_binder_id); R_UNLESS(layer != nullptr, VI::ResultNotFound); + m_surface_flinger->CreateLayer(consumer_binder_id); + *out_layer_id = layer->GetId(); R_SUCCEED(); } Result Container::DestroyLayerLocked(u64 layer_id) { - R_SUCCEED_IF(m_layers.DestroyLayer(layer_id)); - R_THROW(VI::ResultNotFound); + auto* const layer = m_layers.GetLayerById(layer_id); + R_UNLESS(layer != nullptr, VI::ResultNotFound); + + m_surface_flinger->DestroyLayer(layer->GetConsumerBinderId()); + m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), + layer->GetProducerBinderId()); + m_layers.DestroyLayer(layer_id); + + R_SUCCEED(); } 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 R_UNLESS(!layer->IsOpen(), VI::ResultOperationFailed); R_UNLESS(layer->GetOwnerAruid() == aruid, VI::ResultPermissionDenied); - this->CreateBufferQueueLocked(layer); + layer->Open(); + + if (auto* display = layer->GetDisplay(); display != nullptr) { + m_surface_flinger->AddLayerToDisplayStack(display->GetId(), layer->GetConsumerBinderId()); + } + *out_producer_binder_id = layer->GetProducerBinderId(); R_SUCCEED(); @@ -192,30 +206,14 @@ Result Container::CloseLayerLocked(u64 layer_id) { R_UNLESS(layer != nullptr, VI::ResultNotFound); R_UNLESS(layer->IsOpen(), VI::ResultOperationFailed); - this->DestroyBufferQueueLocked(layer); - - R_SUCCEED(); -} - -void Container::CreateBufferQueueLocked(Layer* layer) { - s32 consumer_binder_id, producer_binder_id; - m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); - layer->Open(consumer_binder_id, producer_binder_id); - - if (auto* display = layer->GetDisplay(); display != nullptr) { - m_surface_flinger->AddLayerToDisplayStack(display->GetId(), consumer_binder_id); - } -} - -void Container::DestroyBufferQueueLocked(Layer* layer) { if (auto* display = layer->GetDisplay(); display != nullptr) { m_surface_flinger->RemoveLayerFromDisplayStack(display->GetId(), layer->GetConsumerBinderId()); } layer->Close(); - m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), - layer->GetProducerBinderId()); + + R_SUCCEED(); } 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: Result OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid); Result CloseLayerLocked(u64 layer_id); - void CreateBufferQueueLocked(Layer* layer); - void DestroyBufferQueueLocked(Layer* layer); - public: bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); 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 { public: constexpr Layer() = default; - void Initialize(u64 id, u64 owner_aruid, Display* display) { + void Initialize(u64 id, u64 owner_aruid, Display* display, s32 consumer_binder_id, + s32 producer_binder_id) { m_id = id; m_owner_aruid = owner_aruid; m_display = display; + m_consumer_binder_id = consumer_binder_id; + m_producer_binder_id = producer_binder_id; m_is_initialized = true; } void Finalize() { m_id = {}; + m_owner_aruid = {}; m_display = {}; + m_consumer_binder_id = {}; + m_producer_binder_id = {}; m_is_initialized = {}; } - void Open(s32 consumer_binder_id, s32 producer_binder_id) { - m_consumer_binder_id = consumer_binder_id; - m_producer_binder_id = producer_binder_id; + void Open() { m_is_open = true; } void Close() { - m_producer_binder_id = {}; - m_consumer_binder_id = {}; - m_is_open = {}; + m_is_open = false; } 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 { public: constexpr LayerList() = default; - Layer* CreateLayer(u64 owner_aruid, Display* display) { + Layer* CreateLayer(u64 owner_aruid, Display* display, s32 consumer_binder_id, + s32 producer_binder_id) { Layer* const layer = GetFreeLayer(); if (!layer) { return nullptr; } - layer->Initialize(++m_next_id, owner_aruid, display); + layer->Initialize(++m_next_id, owner_aruid, display, consumer_binder_id, + producer_binder_id); return layer; } diff --git a/src/core/hle/service/vi/shared_buffer_manager.cpp b/src/core/hle/service/vi/shared_buffer_manager.cpp index 869b18961..12cba16fa 100644 --- a/src/core/hle/service/vi/shared_buffer_manager.cpp +++ b/src/core/hle/service/vi/shared_buffer_manager.cpp @@ -285,7 +285,7 @@ void SharedBufferManager::DestroySession(Kernel::KProcess* owner_process) { auto& session = it->second; // Destroy the layer. - R_ASSERT(m_container.DestroyStrayLayer(session.layer_id)); + m_container.DestroyStrayLayer(session.layer_id); // Close nvmap handle. FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd); @@ -322,8 +322,6 @@ Result SharedBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size, Result SharedBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence, std::array<s32, 4>& out_slot_indexes, s64* out_target_slot, u64 layer_id) { - std::scoped_lock lk{m_guard}; - // Get the producer. std::shared_ptr<android::BufferQueueProducer> producer; R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); @@ -347,8 +345,6 @@ Result SharedBufferManager::PresentSharedFrameBuffer(android::Fence fence, Common::Rectangle<s32> crop_region, u32 transform, s32 swap_interval, u64 layer_id, s64 slot) { - std::scoped_lock lk{m_guard}; - // Get the producer. std::shared_ptr<android::BufferQueueProducer> producer; R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); @@ -379,8 +375,6 @@ Result SharedBufferManager::PresentSharedFrameBuffer(android::Fence fence, } Result SharedBufferManager::CancelSharedFrameBuffer(u64 layer_id, s64 slot) { - std::scoped_lock lk{m_guard}; - // Get the producer. std::shared_ptr<android::BufferQueueProducer> producer; R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); @@ -394,8 +388,6 @@ Result SharedBufferManager::CancelSharedFrameBuffer(u64 layer_id, s64 slot) { Result SharedBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, u64 layer_id) { - std::scoped_lock lk{m_guard}; - // Get the producer. std::shared_ptr<android::BufferQueueProducer> producer; R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); |