perf(sidecar): avoid second hardware warmup readback
This commit is contained in:
@@ -307,10 +307,7 @@ fn paint_hardware_surface_frame(
|
|||||||
if !payloadless_surface_pool_ready(readiness, session.width, session.height) {
|
if !payloadless_surface_pool_ready(readiness, session.width, session.height) {
|
||||||
return paint_readback_frame(host, session, !has_pending_frame);
|
return paint_readback_frame(host, session, !has_pending_frame);
|
||||||
}
|
}
|
||||||
let (outcome, identity) = paint_hardware_surface_report(host, session, !has_pending_frame)?;
|
let (outcome, _) = paint_hardware_surface_report(host, session, !has_pending_frame)?;
|
||||||
if !surface_has_been_published(readiness.published_surface_ids, readiness.tab_id, identity) {
|
|
||||||
return paint_readback_frame(host, session, true);
|
|
||||||
}
|
|
||||||
Ok((outcome, true))
|
Ok((outcome, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,16 +367,15 @@ fn payloadless_surface_pool_ready(
|
|||||||
let matching = published
|
let matching = published
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|identity| identity.width == width && identity.height == height)
|
.filter(|identity| identity.width == width && identity.height == height)
|
||||||
.take(2)
|
|
||||||
.copied()
|
.copied()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if matching.len() < 2 {
|
if matching.is_empty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
!readiness.require_client_ready_surfaces
|
!readiness.require_client_ready_surfaces
|
||||||
|| matching
|
|| matching
|
||||||
.iter()
|
.iter()
|
||||||
.all(|identity| readiness.ready_surface_ids.contains(&identity.surface_id))
|
.any(|identity| readiness.ready_surface_ids.contains(&identity.surface_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
@@ -418,15 +414,6 @@ fn payloadless_readiness<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "hardware-render", target_os = "macos"))]
|
|
||||||
fn surface_has_been_published(
|
|
||||||
published_surface_ids: &HashMap<String, HashSet<IOSurfaceIdentity>>,
|
|
||||||
tab_id: &str,
|
|
||||||
identity: IOSurfaceIdentity,
|
|
||||||
) -> bool {
|
|
||||||
published_surface_ids.get(tab_id).is_some_and(|published| published.contains(&identity))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -444,11 +431,11 @@ mod tests {
|
|||||||
|
|
||||||
#[cfg(all(feature = "hardware-render", target_os = "macos"))]
|
#[cfg(all(feature = "hardware-render", target_os = "macos"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn payloadless_pool_waits_for_client_ready_surfaces_when_required() {
|
fn payloadless_pool_accepts_one_client_ready_surface() {
|
||||||
let published = published_identities([identity(7, 800, 600), identity(8, 800, 600)]);
|
let published = published_identities([identity(7, 800, 600), identity(8, 800, 600)]);
|
||||||
|
|
||||||
assert!(!payloadless_surface_pool_ready(readiness(&published, &[7], true), 800, 600));
|
assert!(!payloadless_surface_pool_ready(readiness(&published, &[], true), 800, 600));
|
||||||
assert!(payloadless_surface_pool_ready(readiness(&published, &[7, 8], true), 800, 600));
|
assert!(payloadless_surface_pool_ready(readiness(&published, &[7], true), 800, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "hardware-render", target_os = "macos"))]
|
#[cfg(all(feature = "hardware-render", target_os = "macos"))]
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
use dpi::PhysicalSize;
|
use dpi::PhysicalSize;
|
||||||
use ely_servo_host::HardwareOffscreenContext;
|
use ely_servo_host::HardwareOffscreenContext;
|
||||||
|
use servo::RenderingContext;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn constructs_or_explains_why_not() {
|
fn constructs_or_explains_why_not() {
|
||||||
@@ -52,6 +53,8 @@ fn extracts_iosurface_mach_port_from_current_surface() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
context.prepare_for_rendering();
|
||||||
|
context.present();
|
||||||
let first = context
|
let first = context
|
||||||
.current_iosurface_mach_port()
|
.current_iosurface_mach_port()
|
||||||
.map_err(|error| format!("first IOSurface mach port extraction failed: {error:?}"))?;
|
.map_err(|error| format!("first IOSurface mach port extraction failed: {error:?}"))?;
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ fn run_live_bench() -> Result<(), Box<dyn Error>> {
|
|||||||
);
|
);
|
||||||
if kind == "hardware" {
|
if kind == "hardware" {
|
||||||
let full_readback_budget = viewport_bytes * u64::from(frames);
|
let full_readback_budget = viewport_bytes * u64::from(frames);
|
||||||
|
assert_eq!(
|
||||||
|
outcome.readback_rgba_bytes, viewport_bytes,
|
||||||
|
"hardware path should read back only the initial visible frame"
|
||||||
|
);
|
||||||
assert!(
|
assert!(
|
||||||
total_rgba_bytes < full_readback_budget,
|
total_rgba_bytes < full_readback_budget,
|
||||||
"hardware path stayed on full readback: {total_rgba_bytes} >= {full_readback_budget}"
|
"hardware path stayed on full readback: {total_rgba_bytes} >= {full_readback_budget}"
|
||||||
|
|||||||
Reference in New Issue
Block a user