-
Notifications
You must be signed in to change notification settings - Fork 167
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
Initial support for DRM async page flip #1335
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1335 +/- ##
==========================================
- Coverage 21.32% 21.23% -0.09%
==========================================
Files 156 156
Lines 25121 25042 -79
==========================================
- Hits 5356 5317 -39
+ Misses 19765 19725 -40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1a8c49e
to
0d62362
Compare
It actually does. |
Yep, it's more or less the only use-case for this. |
src/backend/drm/mod.rs
Outdated
/// Hint for DRM backend on how the surface should be presented | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum PresentationMode { | ||
/// Vertical synchronization | ||
VSync, | ||
/// Thearing presentationres | ||
ASync, | ||
// NOTE: Auto for detecting when thearing is desired would probably go here | ||
} | ||
|
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.
We might be able to get away without introducing some Auto
variant. After all every frame needs to have a preference anyway. By adding PresentationMode
to queue_frame
this can be nicely communicated (nice work btw 👍 ) frame by frame. I think it would be nice to keep it this way and always let downstream decide without some internal mechanism to detect it. What we should do instead is to provide some helper representing some sane behavior that can be used when downstream has no preference on its own.
I was thinking about doing it this way:
- Moving the
PresentationMode
enum to our render element module and introducingRenderElement::presentation_mode(&self) -> PresentationMode
function - Adding a helper to
RenderFrameResult
ofDrmCompositor
to get a sane defaultPresentationMode
The RenderFrameResult
already has a reference to all Element
s assigned to planes, so it should be as easy
as to verify that all planes have something assigned that prefers tearing.
This way downstream should have the complete freedom to decide, but can opt in to auto easily by just forwarding the PresentationMode
from RenderFrameResult
to DrmCompositor::queue_frame
.
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.
Sounds good to me.
The RenderFrameResult already has a reference to all Elements assigned to planes, so it should be as easy
as to verify that all planes have something assigned that prefers tearing.
This is a the part however that might warrent allowing customization in some way (perhaps with a closure, like default_primary_output_compare
?). E.g. some compositors might want to tear if a single element is added to the primary-plane that preferrs tearing (perhaps even dependant on the content-type?). To name a more concrete example, some FPS overlay on an overlay plane shouldn't be blocking tearing of an directly scanned-out fullscreen game on the primary plane. Of course interactions here can be extremly subtle, which is why I would also prefer to just delegate those issues to downstream.
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.
I mean, everything the helper function uses internally should be public accessible. So I don't think we need to complicate the default function, especially as it should be trivial to implement. The FPS overlay is a good example, so maybe just a single parameter if it should only check the primary plane or all assigned planes. Everything more complicated than that might be better handled completely downstream.
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.
Sounds good to me
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.
Done, but on Element
rather than RenderElement
, as R: Renderer
generic was kinda annoying to deal with.
Elements can choose to request VSync, Async, or set no preference. Based on that we search for common denominator.
The whole change is self-contained in this new commit: a7e1c32
74b2cdf
to
a7e1c32
Compare
e141600
to
fb65980
Compare
Ok, I belive this is ready. Although I still can't test the atomic path, even tho my driver started to report Running with |
fn presentation_mode(&self) -> Option<PresentationMode> { | ||
// On Wayland assume VSync as default preference | ||
Some(PresentationMode::VSync) | ||
// TODO: Return Async in case wp_tearing is attatched to the surface |
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.
This is waiting on the tearing control PR?
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.
Yep, or the other way around, I don't care. Although the protocol PR is probably more merge ready. We could also just merge the PRs into one.
Okay, so this is not going to work this way unfortunately. Async page flips have some special limitations we need to account for. For an async page flip to succeed the atomic commit is only allowed to change the framebuffer on the primary plane. Every other change will result in the page flip request to be declined. This unfortunately also includes Not sure what to do about There are also driver specific limitations like for example intel not supporting async page flips if the plane uses some compressed tiling format. So imo the most sane way to handle this is to do best guessing in I prototyped some parts of this and will post a patch when its ready. |
Okay, I put something together that should work (at least it seems to work on my system). Curious if this also works on AMD and Nvidia now @PolyMeilex @YaLTeR @Drakulix |
fb65980
to
c5d0073
Compare
@cmeissl Atomic backend now works on my AMD systems, looks promising. Rebased on master, and cherrypicked the cmeissl's commit (with some minnor reverts of debug code edits) |
c5d0073
to
e62c854
Compare
Confits resolved, everything seems to still work as expected on my AMD machines both with atomic and legacy |
Feedback from the display next hackfest:
|
This allows users to select if frame should be presented with VSync or fully ASync.
blocked by: Smithay/drm-rs#190 (awaiting releasse)blocked by: Smithay/gbm.rs#40related: #1325