Add CPUTiming layer#1
Merged
emrekultursay merged 14 commits intoandroid-graphics:mainfrom Mar 2, 2026
Merged
Conversation
m--koma
reviewed
Feb 27, 2026
m--koma
approved these changes
Feb 27, 2026
m--koma
left a comment
There was a problem hiding this comment.
Awesome job! Just one comment re: Perfetto sources.
olehkuznetsov
approved these changes
Mar 2, 2026
olehkuznetsov
left a comment
There was a problem hiding this comment.
I'm glad we have categories now )
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change adds a new CPUTiming Vulkan layer. It's behavior is identical to the same-named layer in AGI.
Basic Operation:
Timerobject on stack, and then calls the next layer down the chain (or the Vulkan driver if there are no more layers).Timerobject emits a Perfetto start event with the name of the API.Timerobject emits a Perfetto end event.Code Generation
The Vulkan APIs that the layer intercepts, and their implementation (with the stack-allocated
Timerobject) are auto-generated. The code generation is based on the sameBaseGeneratorused by LunarG'sapi_dumpVulkan layer . No new technology was invented for this.Perfetto Dependency
The layer in AGI was using a legacy way (chrome tracing style) when emitting Perfetto events. This change uses the new Perfetto SDK. It uses the amalgamated
perfetto.handperfetto.ccfiles that are downloaded (and can be updated) using a simple Python script (update_perfetto_sdk.py), and are checked-in to source control.This new style also requires the Perfetto capture config to be slightly different. Specifically, on the client-side, we need to use the following to enable this data source:
Platforms
The layer supports Android and Linux. On Android, it emits Perfetto events. On Linux, it measures time using
chronoand prints the name of the API and how long it took to the standard output.Testing:
A test that verifies the Linux version is added. The test is similar to the existing test for LunarG's
api_dumplayer. It runs an app with the layer enabled, and then verifies that thestdoutcontains the expected Vulkan APIs (the test only looks forVkCreateInstancewhich is sufficient for simple validation purposes).The Android version of the layer does not have an automated test. It was tested manually on various Android devices. The following screenshot shows the result of enabling/disabling this new layer on a device with the Samsung Xclipse GPU (S25-FE). See the topmost slices on the Thread-2 track that start with the
vkprefix: