Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Oct 12, 2023

Impelement GPU frame time tracing for metal. Unlike Vulkan, this can't use dummy cmd buffers as those don't seem to ever get an executed callback. Instead we decorate every submitted cmd buffer with tracing functionality, and min/max the timestamps to compute the range of computation time.

@jonahwilliams jonahwilliams marked this pull request as ready for review October 12, 2023 21:01
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

trace_states_[current_state].pending_buffers += 1;

if (@available(ios 10.3, tvos 10.2, macos 10.15, macCatalyst 13.0, *)) {
[buffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has some issues with GPUTracerMTL being deleted (or retained), but I'm not quite sure how to solve that with object-c / c++ interop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks @gaaclarke !

@jonahwilliams
Copy link
Contributor Author

Oh, hmm, I wonder if this available check covers simulators. Need to build for sim locally and confirm

fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Oct 14, 2023
@jonahwilliams
Copy link
Contributor Author

This works on Simulators!

namespace impeller {

void GPUTracerMTL::MarkFrameEnd() {
#ifdef IMPELLER_DEBUG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - rather than guarding each method, just don't even allocate this outside of debug?

(state.largest_timestamp - state.smallest_timestamp) * 1000;
state.smallest_timestamp = std::numeric_limits<float>::max();
state.largest_timestamp = 0;
FML_TRACE_COUNTER("flutter", "GPUTracer",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it should be a constant somewhere so that MTL and VK use the same one always

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would you want this? I can put it in core?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im gonna punt on this - the trace event will probably change a few times

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits, LGTM

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 16, 2023

auto label is removed for flutter/engine/46846, due to - The status or check suite Linux linux_web_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 16, 2023

auto label is removed for flutter/engine/46846, due to - The status or check suite Linux linux_web_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #46846 at sha 212fe99

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2023
@auto-submit auto-submit bot merged commit ade3c05 into flutter:main Oct 16, 2023
@jonahwilliams jonahwilliams deleted the gpu_tracing_metal branch October 16, 2023 22:45
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 17, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 17, 2023
…136695)

flutter/engine@2d55e29...2159fdb

2023-10-17 [email protected] Roll Skia from 751358929d1f to 205b728a8623 (1 revision) (flutter/engine#46982)
2023-10-17 [email protected] Revert "Fix `Platform.script` for flutter_tester" (flutter/engine#46981)
2023-10-16 [email protected] Roll Dart SDK from 12f6559bd6ed to f3e1cd38e8b0 (1 revision) (flutter/engine#46977)
2023-10-16 [email protected] Roll Fuchsia Linux SDK from 6E-cSq679DjzBMcqY... to Y9mDBoH4BSC6pWFXV... (flutter/engine#46974)
2023-10-16 [email protected] Roll Skia from 8919fecf15c1 to 751358929d1f (4 revisions) (flutter/engine#46972)
2023-10-16 [email protected] [Impeller] GPUTracer for Metal. (flutter/engine#46846)
2023-10-16 [email protected] Fix `Platform.script` for flutter_tester (flutter/engine#46911)
2023-10-16 [email protected] Roll Skia from 85c8dca08cbe to 8919fecf15c1 (1 revision) (flutter/engine#46966)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from 6E-cSq679Djz to Y9mDBoH4BSC6

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
Impelement GPU frame time tracing for metal. Unlike Vulkan, this can't use dummy cmd buffers as those don't seem to ever get an executed callback. Instead we decorate every submitted cmd buffer with tracing functionality, and min/max the timestamps to compute the range of computation time.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants