-
Notifications
You must be signed in to change notification settings - Fork 31
First pass at using puffin to display the query results #81
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
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eacc40f
First pass at using puffin to display the query results
Gonkalbell cd5b8ef
Addressing code review feedback and fixing format
Gonkalbell d7883ba
Merge branch 'main' into puffin-implementation
Gonkalbell f079562
Merge remote-tracking branch 'origin/main' into puffin-implementation
Wumpf 6670c19
add changelog entry
Wumpf 6493b40
add explanation to tracy & puffin integrations into lib.rs docs
Wumpf 4e8dab5
Fix ci checks
Wumpf 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use puffin::{GlobalProfiler, NanoSecond, ScopeDetails, StreamInfo, ThreadInfo}; | ||
|
||
use crate::GpuTimerQueryResult; | ||
|
||
/// Visualize the query results in a `puffin::GlobalProfiler`. | ||
pub fn output_frame_to_puffin(profiler: &mut GlobalProfiler, query_result: &[GpuTimerQueryResult]) { | ||
let mut stream_info = StreamInfo::default(); | ||
collect_stream_info_recursive(profiler, &mut stream_info, query_result, 0); | ||
|
||
profiler.report_user_scopes( | ||
ThreadInfo { | ||
start_time_ns: None, | ||
name: "GPU".to_string(), | ||
}, | ||
&stream_info.as_stream_into_ref(), | ||
); | ||
} | ||
|
||
fn collect_stream_info_recursive( | ||
profiler: &mut GlobalProfiler, | ||
stream_info: &mut StreamInfo, | ||
query_result: &[GpuTimerQueryResult], | ||
depth: usize, | ||
) { | ||
let details: Vec<_> = query_result | ||
.iter() | ||
.map(|query| ScopeDetails::from_scope_name(query.label.clone())) | ||
.collect(); | ||
let ids = profiler.register_user_scopes(&details); | ||
for (query, id) in query_result.iter().zip(ids) { | ||
if let Some(time) = &query.time { | ||
let start = (time.start * 1e9) as NanoSecond; | ||
let end = (time.end * 1e9) as NanoSecond; | ||
|
||
stream_info.depth = stream_info.depth.max(depth); | ||
stream_info.num_scopes += 1; | ||
stream_info.range_ns.0 = stream_info.range_ns.0.min(start); | ||
stream_info.range_ns.1 = stream_info.range_ns.0.max(end); | ||
|
||
let (offset, _) = stream_info.stream.begin_scope(|| start, id, ""); | ||
collect_stream_info_recursive(profiler, stream_info, &query.nested_queries, depth + 1); | ||
stream_info.stream.end_scope(offset, end as NanoSecond); | ||
} | ||
} | ||
} |
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.