mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 19:51:52 +01:00
Attempt to signal the vsync event at present time if possible
Some games rely on the vsync event to schedule frames, by matching its timing with presentation we can reduce needless waiting as the game will immediely be able to queue the next frame after presentation.
This commit is contained in:
parent
918a493a45
commit
cc3c869b9f
@ -61,6 +61,7 @@ namespace skyline::gpu {
|
|||||||
|
|
||||||
// Record the current cycle's timestamp and signal the V-Sync event to notify the game that a frame has been displayed
|
// Record the current cycle's timestamp and signal the V-Sync event to notify the game that a frame has been displayed
|
||||||
engine->lastChoreographerTime = frameTimeNanos;
|
engine->lastChoreographerTime = frameTimeNanos;
|
||||||
|
if (!engine->skipSignal.exchange(false))
|
||||||
engine->vsyncEvent->Signal();
|
engine->vsyncEvent->Signal();
|
||||||
|
|
||||||
// Post the frame callback to be triggered on the next display refresh
|
// Post the frame callback to be triggered on the next display refresh
|
||||||
@ -237,6 +238,8 @@ namespace skyline::gpu {
|
|||||||
presentQueue.Process([this](const PresentableFrame &frame) {
|
presentQueue.Process([this](const PresentableFrame &frame) {
|
||||||
PresentFrame(frame);
|
PresentFrame(frame);
|
||||||
frame.presentCallback(); // We're calling the callback here as it's outside of all the locks in PresentFrame
|
frame.presentCallback(); // We're calling the callback here as it's outside of all the locks in PresentFrame
|
||||||
|
skipSignal = true;
|
||||||
|
vsyncEvent->Signal();
|
||||||
}, [] {});
|
}, [] {});
|
||||||
} catch (const signal::SignalException &e) {
|
} catch (const signal::SignalException &e) {
|
||||||
Logger::Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
Logger::Error("{}\nStack Trace:{}", e.what(), state.loader->GetStackTrace(e.frames));
|
||||||
|
@ -52,6 +52,7 @@ namespace skyline::gpu {
|
|||||||
perfetto::Track presentationTrack; //!< Perfetto track used for presentation events
|
perfetto::Track presentationTrack; //!< Perfetto track used for presentation events
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
std::atomic<bool> skipSignal; //!< If true, the next signal will be skipped by the choreographer thread
|
||||||
std::shared_ptr<kernel::type::KEvent> vsyncEvent; //!< Signalled every time a frame is drawn
|
std::shared_ptr<kernel::type::KEvent> vsyncEvent; //!< Signalled every time a frame is drawn
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user