yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

vi: connect vsync event handle lifetime to application display service interface

This commit is contained in:
Liam 2024-01-06 23:58:04 -05:00
parent ae88ea79b2
commit ea710e6523
4 changed files with 11 additions and 24 deletions

View File

@ -223,7 +223,8 @@ Result Nvnflinger::FindVsyncEvent(Kernel::KReadableEvent** out_vsync_event, u64
return VI::ResultNotFound; return VI::ResultNotFound;
} }
return display->GetVSyncEvent(out_vsync_event); *out_vsync_event = display->GetVSyncEvent();
return ResultSuccess;
} }
VI::Display* Nvnflinger::FindDisplay(u64 display_id) { VI::Display* Nvnflinger::FindDisplay(u64 display_id) {

View File

@ -71,18 +71,7 @@ size_t Display::GetNumLayers() const {
return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); }); return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); });
} }
Result Display::GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event) { Kernel::KReadableEvent* Display::GetVSyncEvent() {
if (got_vsync_event) {
return ResultPermissionDenied;
}
got_vsync_event = true;
*out_vsync_event = GetVSyncEventUnchecked();
return ResultSuccess;
}
Kernel::KReadableEvent* Display::GetVSyncEventUnchecked() {
return &vsync_event->GetReadableEvent(); return &vsync_event->GetReadableEvent();
} }

View File

@ -74,16 +74,8 @@ public:
std::size_t GetNumLayers() const; std::size_t GetNumLayers() const;
/**
* Gets the internal vsync event.
*
* @returns The internal Vsync event if it has not yet been retrieved,
* VI::ResultPermissionDenied otherwise.
*/
[[nodiscard]] Result GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event);
/// Gets the internal vsync event. /// Gets the internal vsync event.
Kernel::KReadableEvent* GetVSyncEventUnchecked(); Kernel::KReadableEvent* GetVSyncEvent();
/// Signals the internal vsync event. /// Signals the internal vsync event.
void SignalVSyncEvent(); void SignalVSyncEvent();
@ -104,7 +96,6 @@ public:
/// Resets the display for a new connection. /// Resets the display for a new connection.
void Reset() { void Reset() {
layers.clear(); layers.clear();
got_vsync_event = false;
} }
/// Attempts to find a layer with the given ID. /// Attempts to find a layer with the given ID.
@ -133,7 +124,6 @@ private:
std::vector<std::unique_ptr<Layer>> layers; std::vector<std::unique_ptr<Layer>> layers;
Kernel::KEvent* vsync_event{}; Kernel::KEvent* vsync_event{};
bool got_vsync_event{false};
}; };
} // namespace Service::VI } // namespace Service::VI

View File

@ -808,6 +808,12 @@ private:
rb.Push(result); rb.Push(result);
return; return;
} }
if (vsync_event_fetched) {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(VI::ResultPermissionDenied);
return;
}
vsync_event_fetched = true;
IPC::ResponseBuilder rb{ctx, 2, 1}; IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -901,6 +907,7 @@ private:
Nvnflinger::Nvnflinger& nvnflinger; Nvnflinger::Nvnflinger& nvnflinger;
Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
bool vsync_event_fetched{false};
}; };
static bool IsValidServiceAccess(Permission permission, Policy policy) { static bool IsValidServiceAccess(Permission permission, Policy policy) {