-
Notifications
You must be signed in to change notification settings - Fork 953
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
Extended Presentation API Investigation #2869
Comments
For EGL, the WSI can do present with damage if the EGL_KHR_swap_buffers_with_damage extension is supported. |
Random thoughts incoming:
Taking a step back and thinking about how one would want to use this - the presentation and display refresh statistics provide information that can be used to make some kind of estimation/prediction for frame pacing, and the presentation descriptor then allows making an attempt at controlling presentation of a given frame. I'd have to think through it more thoroughly to be able to figure out whether it's sufficient and ergonomic. |
@superdump There is, it's a bit complicated, but should be implementable within winit. You can get very specific timing info about all your monitors. Now that winit exposes micro-hertz refresh it should be usable for pacing. We just also need to expose the precision of the hz measurement. |
I'm not sure what the status here is, but I'd love to implement the |
@badicsalex Sorry this totally got lost in the information firehose. None of this (outside of getting cpu-side presentation timestamps) is implemented yet and we'd love help! Come on our matrix and chat, that'd probably be the easiest way to sync up. |
@cwfitzgerald thanks for the answer. We've investigated the issue in detail since then, and it seems that VK_GOOGLE_display_timing wouldn't give us much over simply measuring the acquire times of a simple FIFO mode, so we didn't pursue that angle any further. |
I talked a bit with @DJMcNab at RustNL last week, and he said that partial present functionality was important to the Xilem team. |
I'm still interested in this too, just haven't gotten around to properly look at this. I have a fork somewhere that implement a crude way of getting presentation information on Apple hardware, but I think the main problem here is finding out to integrate data from the different APIs into wgpu's data model. Having precise statistics about when presentation happened is super crucial for my use case and now that the rest of my project is somewhat shaping up, I might have another look. On a side note, I'd also be interested in running a handler as soon as possible after frame presentation, but I'm not sure if that is even possible outside of Apple/Metal. |
Does anyone know if Additionally, can we add Scheduling animations is possible but I haven't found a function to schedule presents from a swapchain yet; perhaps because that can/should be done through the API of choice instead (i.e. directly on |
Not directly. I'm using it with D3D12, and I'm using D3D11 to make the buffers and do a blit into the final image.
Sure. We need to support dcomp anyway to get transparent windows on windows. IDXGIOutput also has WaitForVsync, but that's only available if you're on the adapter powering the monitor (or can figure out what monitor you're on)
You can from IPresentationManager https://learn.microsoft.com/en-us/windows/win32/api/presentation/nf-presentation-ipresentationmanager-settargettime and https://learn.microsoft.com/en-us/windows/win32/api/presentation/nf-presentation-ipresentationmanager-setpreferredpresentduration. Seems to work well, and SetPreferredPresentDuration seems to interact in the expected way with VRR. I have personally given up on trying to figure out when the next present will happen as there are way too many factors, and instead focused on presenting a smooth series of frames and with corresponding present times. |
Right, have you also tried calling
I'll rely on you to edit that into your own post :)
Sorry for not being clear - I meant by using
And |
Just to throw another wrench into this, since recentish Android API levels, you are somewhat expected to use However, this API I believe is incompatible with using an underlying Vulkan Swapchain object. Currently, the things stopping experimenting with this externally are:
(Edited to add more content as my control key got stuck and submitted without intention) |
@DJMcNab this paragraph still looks unfinished (even though the gist of all the features you get are derived by following the link). But yes, I've asked upstream (as a final drive-by question in https://issuetracker.google.com/issues/320706287) whether we can get access to the buffer creation and (de)queueing mechanisms that are already used internally by Android's |
That would probably be helpful; this whole thing is rather messy. |
Context
I'm working on frame pacing and we need some help from the api. The difficulty of designing this api is each WSI has different pieces of information and give it to us in different ways.
Supersedes #682
Supersedes #2650
Investigation
We have the following major WSIs to think about:
And we have the following primatives:
Notes:
1a. Presentation times need to be queried actively, it doesn't get told to us.
1b. Presentation times are given through an event queue.
1c. Presentation times are given through callbacks.
2. Can only wait for 1-3 frames ago, not a particular frame.
3. Windows 8+/Windows 7 Platform Update
4. You can schedule presentation for N vblanks from now.
5. Via NSScreen - need to figure out how to get NSScreen from metal layer.
Because of the diversity of the platforms, I think this will inherently be a leaky abstraction - this is okay - we shouldn't try to hide platform differences, just make it as easy to use as possible.
As such I have put together the following api.
Api Suggestion
Feature
First is to add a single Feature.
Presentation Features
Add an extended presentation capabilities bitflag that is queryable from the surface. I am separating this from regular features because they are more useful as default-on. Having the single feature means that users have to consciously enable it, but without needing to individually modulate them.
Presentation Signature
The presentation signature will be changed to the following.
Presentation Timestamp
Because different apis use different timestamps - we need a way of correlating these timestamps with various other clocks. The clocks used are as follows on each WSI:
Add the following function to the surface.
Which will let people write the following code to correlate instants and presentation timestamps. We need this because
Instant
s need to be treated as completely opaque as the clock they use can change at any time. In most cases these are actually the same clock, but this is what we get.Presentation Statistics
Because of the difference in how all the apis query stats, we need to abstract this carefully. We use a query-based "presentation statistics queue".
vkGetPastPresentationTimingGOOGLE
which drains the queue.Presentation Wait
First add the following member to SurfaceConfiguration:
This adjusts either the swapchain frame count to
value + 1
- or sets SetMaximumFrameLatency to the value given, or uses a wait-for-present in the acquire method to limit rendering such that it acts like it's avalue + 1
swapchain frame set.Monitor Information
Getting exact frequencies of monitors is important for pacing - they can be derived from presentation stats, but an explicit api is more precise if it is available.
Conclusion
This is obviously one hell of an api change, and this doesn't have to happen all at once, but this investigating should give us the place to discuss the changes and make sure it provides the information needed.
The text was updated successfully, but these errors were encountered: