diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2022-09-26 03:20:36 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2022-09-26 03:33:36 +0200 |
commit | 41e855bd427e07ade6b9292e12bbe5a7c4e76a69 (patch) | |
tree | a270ca94eabc45a52af899e70c1d72e8ab5b18be /src/core/hle/service/vi/display | |
parent | service: vi: Move VI results into its own file (diff) | |
download | yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.tar yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.tar.gz yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.tar.bz2 yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.tar.lz yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.tar.xz yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.tar.zst yuzu-41e855bd427e07ade6b9292e12bbe5a7c4e76a69.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/vi/display/vi_display.cpp | 15 | ||||
-rw-r--r-- | src/core/hle/service/vi/display/vi_display.h | 14 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index b34febb50..aa49aa775 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -19,6 +19,7 @@ #include "core/hle/service/nvflinger/hos_binder_driver_server.h" #include "core/hle/service/vi/display/vi_display.h" #include "core/hle/service/vi/layer/vi_layer.h" +#include "core/hle/service/vi/vi_results.h" namespace Service::VI { @@ -55,8 +56,18 @@ const Layer& Display::GetLayer(std::size_t index) const { return *layers.at(index); } -Kernel::KReadableEvent& Display::GetVSyncEvent() { - return vsync_event->GetReadableEvent(); +ResultVal<Kernel::KReadableEvent*> Display::GetVSyncEvent() { + if (got_vsync_event) { + return ResultPermissionDenied; + } + + got_vsync_event = true; + + return GetVSyncEventUnchecked(); +} + +Kernel::KReadableEvent* Display::GetVSyncEventUnchecked() { + return &vsync_event->GetReadableEvent(); } void Display::SignalVSyncEvent() { diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 3838bb599..8dbb0ef80 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -9,6 +9,7 @@ #include "common/common_funcs.h" #include "common/common_types.h" +#include "core/hle/result.h" namespace Kernel { class KEvent; @@ -73,8 +74,16 @@ public: return layers.size(); } - /// Gets the readable vsync event. - Kernel::KReadableEvent& GetVSyncEvent(); + /** + * Gets the internal vsync event. + * + * @returns The internal Vsync event if it has not yet been retrieved, + * VI::ResultPermissionDenied otherwise. + */ + [[nodiscard]] ResultVal<Kernel::KReadableEvent*> GetVSyncEvent(); + + /// Gets the internal vsync event. + Kernel::KReadableEvent* GetVSyncEventUnchecked(); /// Signals the internal vsync event. void SignalVSyncEvent(); @@ -118,6 +127,7 @@ private: std::vector<std::unique_ptr<Layer>> layers; Kernel::KEvent* vsync_event{}; + bool got_vsync_event{false}; }; } // namespace Service::VI |