forked from LunarG/VulkanTools
-
Notifications
You must be signed in to change notification settings - Fork 3
Integrate Vulkan Screenshot Layer with Perfetto #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
m--koma
merged 23 commits into
android-graphics:main
from
m--koma:perfetto_screenshot_clean
Apr 17, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0c295c2
Update Perfetto files to include changes made in PR #5348.
m--koma 0de983b
Run clang-format on screenshot.cpp.
m--koma 8a9b212
Write screenshots captured by layer into Perfetto file.
m--koma d9c2b5d
Fix Windows/MinGW build by linking Winsock for Perfetto.
m--koma 269aa4c
Fix unresolved external symbol for TrackEventDataSource on Windows.
m--koma 3c088f0
Refactor perfetto helpers to be per-layer for screenshots
m--koma 13c89fb
Revert changes to perfetto_helpers to focus on screenshots
m--koma 0be5093
Rename Perfetto category to VulkanScreenshots
m--koma f57d7c3
Refactor Vulkan screenshot layer: remove boilerplate, rename function…
m--koma 3f0faa6
Mark screenshots as TrackEvent::TYPE_INSTANT.
m--koma 500bf04
Refactor screenshot layer to support dual output (Perfetto + File) an…
m--koma 95b1b45
Refactor screenshot writers, use C++20
m--koma c0182ee
Fix Windows CI linker error and apply code formatting
m--koma a462ab9
Early exit ScreenshotDataSource if the write setting is FILE.
m--koma 29e00c5
s/globalScreenshotWriter/screenshotWriter
m--koma c6d4295
A few clean ups.
m--koma b34fe6c
Remove explicit screenshot:: namespace and update pause logic
m--koma 8163eb0
Rename updateLayerSettings to controlPause
m--koma d6d8771
Add atomic store for pauseCapture, and remove isPerfetto() checks
m--koma 461f2d0
Update canControlPause() logic; re-run clang.
m--koma 726cecc
Move imports and ScreenshotQueueData to .cpp file
m--koma 5768066
Reorder headers.
m--koma d847d98
Merge branch 'main' into perfetto_screenshot_clean
m--koma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #include "screenshots_perfetto_helpers.h" | ||
| #include <atomic> | ||
| #include <thread> | ||
| #include <mutex> | ||
| #include <condition_variable> | ||
| #include <list> | ||
|
|
||
| #ifdef ANDROID | ||
| #include <android/log.h> | ||
| #endif | ||
|
|
||
| #include "screenshot_writer.h" | ||
|
|
||
|
m--koma marked this conversation as resolved.
|
||
| namespace screenshot { | ||
| struct ScreenshotQueueData; | ||
| extern std::atomic_bool pauseCapture; | ||
| extern std::mutex globalLock; | ||
| extern std::condition_variable screenshotSavedCV; | ||
| extern std::list<std::shared_ptr<ScreenshotQueueData>> screenshotsData; | ||
| } // namespace screenshot | ||
|
|
||
| PERFETTO_DEFINE_CATEGORIES(perfetto::Category("VulkanScreenshots").SetDescription("Vulkan Layer Screenshots")); | ||
|
|
||
| PERFETTO_TRACK_EVENT_STATIC_STORAGE(); | ||
|
|
||
| void InitializeScreenshotsPerfetto() { | ||
| std::atomic_store(&screenshot::pauseCapture, true); | ||
|
|
||
| perfetto::TracingInitArgs args; | ||
| // The backends determine where trace events are recorded. | ||
| // kSystemBackend connects to the system traced service (e.g. on Android). | ||
| args.backends = perfetto::kSystemBackend; | ||
|
|
||
| perfetto::Tracing::Initialize(args); | ||
| perfetto::TrackEvent::Register(); | ||
|
|
||
| perfetto::DataSourceDescriptor dsd; | ||
| dsd.set_name("VulkanScreenshots"); | ||
| ScreenshotDataSource::Register(dsd); | ||
| } | ||
|
olehkuznetsov marked this conversation as resolved.
|
||
|
|
||
| void ScreenshotDataSource::OnStart(const StartArgs&) { | ||
| #ifdef ANDROID | ||
| __android_log_print(ANDROID_LOG_INFO, "screenshot", "ScreenshotDataSource::OnStart called"); | ||
| #endif | ||
| std::atomic_store(&screenshot::pauseCapture, false); | ||
| } | ||
|
|
||
| void ScreenshotDataSource::OnStop(const StopArgs& args) { | ||
| #ifdef ANDROID | ||
| __android_log_print(ANDROID_LOG_INFO, "screenshot", "ScreenshotDataSource::OnStop called"); | ||
| #endif | ||
|
|
||
| std::atomic_store(&screenshot::pauseCapture, true); | ||
|
m--koma marked this conversation as resolved.
|
||
| auto async_stop_closure = args.HandleStopAsynchronously(); | ||
|
|
||
|
m--koma marked this conversation as resolved.
|
||
| std::thread([stop_closure = std::move(async_stop_closure)]() { | ||
| { | ||
| std::unique_lock<std::mutex> lock(screenshot::globalLock); | ||
| screenshot::screenshotSavedCV.wait(lock, [] { return screenshot::screenshotsData.empty(); }); | ||
| } | ||
|
|
||
| // Explicitly notify Perfetto that this data source is now ready to be destroyed. | ||
| stop_closure(); | ||
| }).detach(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #ifndef LAYERSVT_SCREENSHOTS_PERFETTO_HELPERS_H | ||
| #define LAYERSVT_SCREENSHOTS_PERFETTO_HELPERS_H | ||
|
|
||
| #include "perfetto.h" | ||
|
|
||
| class ScreenshotDataSource : public perfetto::DataSource<ScreenshotDataSource> { | ||
|
m--koma marked this conversation as resolved.
|
||
| public: | ||
| void OnStart(const StartArgs&) override; | ||
| void OnStop(const StopArgs& args) override; | ||
| }; | ||
|
|
||
| void InitializeScreenshotsPerfetto(); | ||
|
|
||
| #endif // LAYERSVT_SCREENSHOTS_PERFETTO_HELPERS_H | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.