-
Notifications
You must be signed in to change notification settings - Fork 932
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
metal: implement get_timestamp_period #2528
Conversation
The numbers do mostly check out, intel's period is 83 1/3, though we might want to clamp it so it doesn't go below 1, AMD's should be 1. |
wgpu-hal/src/metal/mod.rs
Outdated
} | ||
|
||
let timestamps1 = [std::ptr::null_mut::<Object>(); 2]; | ||
let () = msg_send![device, sampleTimestamps:×tamps1[0] gpuTimestamp:×tamps1[1]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't there be some kind of work between consecutive invocations of the timestamps? or do you think the resolution here is already enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apple suggested call it at least twice, once when creating a command buffer and a second time inside the command buffer’s completion handler, but that path can't be implemented simply here, and I don't know if it makes sense to create a command buffer for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the whole get_timestamp_period
is not in WebGPU. So we don't have to try implementing it, technically, and could come up with an entirely different API. How about no timestamp period at all? User gets some timestamps, and they can use it for comparison, but it's not really tracking absolute time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the timestamps API is still in discussion? gpuweb/gpuweb#2642
Description
Implemented by referring to Apple's Correlating CPU and GPU Timestamps
Metal
sampleTimestamps:gpuTimestamp:
API available on iOS | iPadOS 14 and macOS 10.15+, but on old A8 chip, the timestamp value obtained by this API is 0.Testing
On all tested Apple silicon (A-series + M1), obtained cpu_timestamp equals to gpu_timestamp:
On iPad mini4(iPadOS 14.7.1),
sampleTimestamps: gpuTimestamp:
alway get 0M1 Mac
get_timestamp_period
alway equal 1.0iPad Pro 2018
get_timestamp_period
alway equal 1.0iPhone 12 Pro
get_timestamp_period
alway equal 1.0Intel Mac with UHD Graphics 630
Intel Mac with AMD Radeon Pro 560X