Compare commits

..
Author SHA1 Message Date
YXC0915 d4627603b5 Fix Navi 31 window presentation on Windows
Queue Runtime Alpha / alpha (push) Canceled after 0s
2026-12-06 19:21:20 +08:00
2 changed files with 38 additions and 4 deletions

No files matched your search

+6 -1
View File
@@ -54,7 +54,12 @@ pub(super) fn sink(
shown: &Arc<Shown>,
presented: &Arc<Presented<RtPlatform>>,
) -> Option<Arc<dyn FrameSink>> {
let draw = ScanoutDraw::new(platform, region, shown, presented)?;
let mut draw = ScanoutDraw::new(platform, region, shown, presented)?;
let gpu = draw.device.facts();
// On Windows, Navi 31 (1002:744c, reported on a 7900 GRE) can lose the Vulkan
// device when the first desktop IOSurface is copied directly to the swapchain.
draw.sample_presented_surface =
cfg!(windows) && (gpu.vendor_id, gpu.device_id) == (0x1002, 0x744c);
Some(Arc::new(RtScanoutSink {
draw: Arc::new(draw),
routed: AtomicBool::new(false),
+32 -3
View File
@@ -25,8 +25,9 @@
//! texture to texture, where the two have one pixel format (BGRA8, with or without sRGB) and the
//! surface is the size of the image's place ("Sizes"), and otherwise a draw of the display's
//! present shaders, which sample the surface in its own format (WindowServer's display surfaces
//! are 10-bit, `BGR10A2Unorm`) and write the drawable's. The first surface of each format
//! is logged.
//! are 10-bit, `BGR10A2Unorm`) and write the drawable's. A window can also require the
//! sampled path for a matching format and size (see `rt_window`). The first surface of each
//! format is logged.
//!
//! **The display's view.** The passes that sample a presented surface (the present shaders'
//! and the colour's) read its texture through the display's own view of it
@@ -281,6 +282,8 @@ pub(crate) struct ScanoutDraw<P: Platform> {
shown: Arc<Shown>,
/// The surface the display pipe shows, if any, in place of the scanout.
presented: Arc<Presented<P>>,
/// Sample presented surfaces even when they would otherwise be copied to the window.
pub(super) sample_presented_surface: bool,
/// The device's recoveries ([`GpuDevice::recoveries`]) when the objects below were made: a
/// draw that finds the count changed makes them again ([`Self::forget_if_recovered`]).
///
@@ -709,6 +712,7 @@ impl<P: ApiPlatform> ScanoutDraw<P> {
route: Mutex::new(None),
shown: Arc::clone(shown),
presented: Arc::clone(presented),
sample_presented_surface: false,
made_at,
converter: Kept::new(),
color_functions: Kept::new(),
@@ -1253,7 +1257,7 @@ impl<P: ApiPlatform> ScanoutDraw<P> {
// the place (the module doc, "Sizes").
let unscaled = (surface.width(), surface.height()) == (region.width, region.height);
let frame = (surface.width(), surface.height());
let drawn = if color.is_none() && copied && unscaled {
let drawn = if !self.sample_presented_surface && color.is_none() && copied && unscaled {
self.note_route("a presented surface, copied", frame, region);
self.encode_surface(&surface, texture, region, recorded)
} else {
@@ -3882,6 +3886,31 @@ mod tests {
})
}
#[test]
fn sampled_window_presents_a_matching_bgra8_surface_without_a_copy() {
let (platform, mut draw, presented, drawable) = rig();
draw.sample_presented_surface = true;
let log = platform.call_log();
let mark = log.mark();
let _ = draw
.encode(&drawable, WHOLE, None, None)
.expect("the scanout");
assert_eq!(count_since(&platform, mark, COPY_IN), 1);
let surface = texture(&draw, 80);
let _held = show_held(&presented, &surface, false);
let mark = log.mark();
let _ = draw
.encode(&drawable, WHOLE, None, None)
.expect("a BGRA8 surface");
let texture_copy = "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:\
toTexture:";
assert_eq!(starting(&platform, mark, texture_copy), 0);
assert_eq!(count_since(&platform, mark, NEW_VIEW), 1);
assert_eq!(count_since(&platform, mark, DRAW), 1);
}
/// At the display's first mode, each frame the size of its place (the window's pixels), every
/// draw is the one it was before the display offered smaller modes, and makes nothing more:
/// the scanout a copy from its pages; a BGRA8 surface a texture copy, with no view; a 10-bit