1
0
Fork 0
forked from wry/wry

wayland: implement commit-timing-v1

This commit is contained in:
Julian Orth 2024-09-26 16:18:17 +02:00
parent d45aaffdb3
commit fac5445f2e
19 changed files with 434 additions and 15 deletions

View file

@ -101,6 +101,9 @@ impl MetalConnector {
if !self.can_present.get() {
continue;
}
let Some(node) = self.state.root.outputs.get(&self.connector_id) else {
continue;
};
let mut expected_sequence = self.sequence.get() + 1;
let mut start = Time::now_unchecked();
let use_frame_scheduling = !self.try_async_flip();
@ -118,7 +121,15 @@ impl MetalConnector {
}
}
frame!(frame_name);
if let Err(e) = self.present_once().await {
{
let now = start.nsec();
let flip = match self.try_async_flip() {
true => now,
false => self.next_vblank_nsec.get(),
};
node.before_latch(flip).await;
}
if let Err(e) = self.present_once(&node).await {
log::error!("Could not present: {}", ErrorFmt(e));
continue;
}
@ -138,7 +149,7 @@ impl MetalConnector {
}
}
async fn present_once(&self) -> Result<(), MetalError> {
async fn present_once(&self, node: &Rc<OutputNode>) -> Result<(), MetalError> {
let version = self.version.get();
if !self.can_present.get() {
return Ok(());
@ -146,9 +157,6 @@ impl MetalConnector {
if !self.backend.check_render_context(&self.dev) {
return Ok(());
}
let Some(node) = self.state.root.outputs.get(&self.connector_id) else {
return Ok(());
};
let crtc = match self.crtc.get() {
Some(crtc) => crtc,
_ => return Ok(()),

View file

@ -13,6 +13,7 @@ use {
gfx_api::{AcquireSync, GfxContext, GfxError, GfxFramebuffer, GfxTexture, ReleaseSync},
ifs::wl_output::OutputId,
state::State,
time::Time,
utils::{
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, numcell::NumCell,
queue::AsyncQueue, syncqueue::SyncQueue,
@ -745,6 +746,8 @@ impl XBackend {
image.last_serial.set(serial);
if let Some(node) = self.state.root.outputs.get(&output.id) {
let now = Time::now_unchecked().nsec();
node.before_latch(now).await;
let res = self.state.present_output(
&node,
&image.fb.get(),