Debian Codegraph @

Source/Core/VideoCommon/VideoEvents.h

raw symbols SCIP
1 // Copyright 2023 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <string_view>
7 #include <vector>
8
9 #include "Common/CommonTypes.h"
10 #include "Common/HookableEvent.h"
11
12 namespace Core
13 {
14 class System;
15 }
16
17 struct PresentInfo
18 {
19 enum class PresentReason
20 {
21 Immediate, // FIFO is Presenting the XFB immediately, straight after the XFB copy
22 VideoInterface, // VideoInterface has triggered a present with a new frame
23 VideoInterfaceDuplicate, // VideoInterface has triggered a present with a duplicate frame
24 };
25
26 // The number of (unique) frames since the emulated console booted
27 u64 frame_count = 0;
28
29 // The number of presents since the video backend was initialized.
30 // never goes backwards.
31 u64 present_count = 0;
32
33 // The frame is identical to the previous frame
34 PresentReason reason = PresentReason::Immediate;
35
36 // The exact emulated time of the when real hardware would have presented this frame
37 u64 emulated_timestamp = 0;
38
39 TimePoint intended_present_time{};
40
41 // AfterPresent only: The actual time the frame was presented
42 TimePoint actual_present_time{};
43
44 enum class PresentTimeAccuracy
45 {
46 // The Driver/OS has given us an exact timestamp of when the first line of the frame started
47 // scanning out to the monitor
48 PresentOnScreenExact,
49
50 // An approximate timestamp of scanout.
51 PresentOnScreen,
52
53 // Dolphin doesn't have visibility of the present time. But the present operation has
54 // been queued with the GPU driver and will happen in the near future.
55 PresentInProgress,
56
57 // Not implemented
58 Unimplemented,
59 };
60
61 // Accuracy of actual_present_time
62 PresentTimeAccuracy present_time_accuracy = PresentTimeAccuracy::Unimplemented;
63
64 std::vector<std::string_view> xfb_copy_hashes;
65 };
66
67 struct VideoEvents
68 {
69 // Called when certain video config setting are changed
70 Common::HookableEvent<u32> config_changed_event;
71
72 // An event called just before the first draw call of a frame
73 Common::HookableEvent<> before_frame_event;
74
75 // An event called after the frame XFB copy begins processing on the host GPU.
76 // Useful for "once per frame" usecases.
77 // Note: In a few rare cases, games do multiple XFB copies per frame and join them while
78 // presenting.
79 // If this matters to your usecase, you should use BeforePresent instead.
80 Common::HookableEvent<Core::System&> after_frame_event;
81
82 // An event called just as a frame is queued for presentation.
83 // The exact timing of this event depends on the "Immediately Present XFB" option.
84 //
85 // If enabled, this event will trigger immediately after AfterFrame
86 // If disabled, this event won't trigger until the emulated interface starts drawing out a new
87 // frame.
88 //
89 // frame_count: The number of frames
90 Common::HookableEvent<PresentInfo&> before_present_event;
91
92 // An event that is triggered after a frame is presented.
93 // The exact timing of this event depends on backend/driver support.
94 Common::HookableEvent<PresentInfo&> after_present_event;
95
96 // An end of frame event that runs on the CPU thread
97 Common::HookableEvent<> vi_end_field_event;
98 };
99
100 VideoEvents& GetVideoEvents();