Fix V-Sync KEvent construction order

The V-Sync `KEvent` would be used by the presentation thread prior to construction leading to dereferencing an invalid value, this has been fixed by changing the order of construction to move the construction of the presentation thread after the V-Sync event.
This commit is contained in:
Billy Laws 2022-07-29 03:16:06 +05:30 committed by PixelyIon
parent ffad246d67
commit 35133381b6
No known key found for this signature in database
GPG Key ID: 11BC6C3201BC2C05
2 changed files with 6 additions and 4 deletions

View File

@ -26,9 +26,9 @@ namespace skyline::gpu {
gpu{gpu},
acquireFence{gpu.vkDevice, vk::FenceCreateInfo{}},
presentationTrack{static_cast<u64>(trace::TrackIds::Presentation), perfetto::ProcessTrack::Current()},
vsyncEvent{std::make_shared<kernel::type::KEvent>(state, true)},
choreographerThread{&PresentationEngine::ChoreographerThread, this},
presentationThread{&PresentationEngine::PresentationThread, this},
vsyncEvent{std::make_shared<kernel::type::KEvent>(state, true)} {
presentationThread{&PresentationEngine::PresentationThread, this} {
auto desc{presentationTrack.Serialize()};
desc.set_name("Presentation");
perfetto::TrackEvent::SetTrackDescriptor(presentationTrack, desc);

View File

@ -47,6 +47,10 @@ namespace skyline::gpu {
i64 averageFrametimeDeviationNs{}; //!< The average deviation of frametimes in nanoseconds
perfetto::Track presentationTrack; //!< Perfetto track used for presentation events
public:
std::shared_ptr<kernel::type::KEvent> vsyncEvent; //!< Signalled every time a frame is drawn
private:
std::thread choreographerThread; //!< A thread for signalling the V-Sync event and measure the refresh cycle duration using AChoreographer
ALooper *choreographerLooper{};
i64 lastChoreographerTime{}; //!< The timestamp of the last invocation of Choreographer::doFrame
@ -97,8 +101,6 @@ namespace skyline::gpu {
void UpdateSwapchain(texture::Format format, texture::Dimensions extent);
public:
std::shared_ptr<kernel::type::KEvent> vsyncEvent; //!< Signalled every time a frame is drawn
PresentationEngine(const DeviceState &state, GPU &gpu);
~PresentationEngine();