diff options
| author | Scott Mansell <phiren@gmail.com> | 2023-01-30 22:36:25 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2023-01-31 19:41:24 +1300 |
| commit | 154cb4f722a9996a4134463e64c85c6bfa25d8bf (patch) | |
| tree | 7dc4583afd2fb8ec494032839439314ef8ddae3d /Source/Core/VideoCommon | |
| parent | d6cd8de1a7c28629ee7680ee20082608b5f84a29 (diff) | |
Introduce an Event system to VideoCommon
A lot of the remaining complexity in Renderer is the massive Swap function
which tries to handle a bunch of FrameBegin/FrameEnd events.
Rather than create a new place for it. This event system will try
to distribute it all over the place
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoEvents.h | 84 |
2 files changed, 85 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index 4507904afd..5428facc55 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -163,6 +163,7 @@ add_library(videocommon VertexShaderManager.h VideoBackendBase.cpp VideoBackendBase.h + VideoEvents.h VideoCommon.h VideoConfig.cpp VideoConfig.h diff --git a/Source/Core/VideoCommon/VideoEvents.h b/Source/Core/VideoCommon/VideoEvents.h new file mode 100644 index 0000000000..bb95296ebd --- /dev/null +++ b/Source/Core/VideoCommon/VideoEvents.h @@ -0,0 +1,84 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "Common/CommonTypes.h" +#include "Common/EventHook.h" + + +// Called when certain video config setting are changed +using ConfigChangedEvent = Event<"ConfigChanged", u32>; + +// An event called just before the first draw call of a frame +using BeforeFrameEvent = Event<"BeforeFrame">; + +// An event called after the frame XFB copy begins processing on the host GPU. +// Useful for "once per frame" usecases. +// Note: In a few rare cases, games do multiple XFB copies per frame and join them while presenting. +// If this matters to your usecase, you should use BeforePresent instead. +using AfterFrameEvent = Event<"AfterFrame">; + +struct PresentInfo +{ + enum class PresentReason + { + Immediate, // FIFO is Presenting the XFB immediately, straight after the XFB copy + VideoInterface, // VideoInterface has triggered a present with a new frame + VideoInterfaceDuplicate, // VideoInterface has triggered a present with a duplicate frame + }; + + // The number of (unique) frames since the emulated console booted + u64 frame_count; + + + // The number of presents since the video backend was initialized. + // never goes backwards. + u64 present_count; + + // The frame is identical to the previous frame + PresentReason reason; + + // The exact emulated time of the when real hardware would have presented this frame + // FIXME: Immediate should predict the timestamp of this present + u64 emulated_timestamp; + + // TODO: + // u64 intended_present_time; + + // AfterPresent only: The actual time the frame was presented + u64 actual_present_time = 0; + + enum class PresentTimeAccuracy + { + // The Driver/OS has given us an exact timestamp of when the first line of the frame started + // scanning out to the monitor + PresentOnScreenExact, + + // An approximate timestamp of scanout. + PresentOnScreen, + + // Dolphin doesn't have visibility of the present time. But the present operation has + // been queued with the GPU driver and will happen in the near future. + PresentInProgress, + + // Not implemented + Unimplemented, + }; + + // Accuracy of actual_present_time + PresentTimeAccuracy present_time_accuracy = PresentTimeAccuracy::Unimplemented; +}; + +// An event called just as a frame is queued for presentation. +// The exact timing of this event depends on the "Immediately Present XFB" option. +// +// If enabled, this event will trigger immediately after AfterFrame +// If disabled, this event won't trigger until the emulated interface starts drawing out a new frame. +// +// frame_count: The number of frames +using BeforePresentEvent = Event<"BeforePresent", PresentInfo&>; + +// An event that is triggered after a frame is presented. +// The exact timing of this event depends on backend/driver support. +using AfterPresentEvent = Event<"AfterPresent", PresentInfo&>; |
