Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

fix interlaced page flip

Layle1255f76fd776
diff --git a/crates/backend-wgpu/src/render.rs b/crates/backend-wgpu/src/render.rs
index fe55cb5..fa5bbd8 100644
--- a/crates/backend-wgpu/src/render.rs
+++ b/crates/backend-wgpu/src/render.rs
@@ -546,7 +546,9 @@ impl GxRenderer {
for part in parts {
let Some((tex, _)) = self.xfb_copies.get(&part.id) else {
- tracing::warn!(id = part.id, "present_xfb: XFB copy not found in cache, skipping part");
+ // Expected when the VI scans a buffer we've never snapshotted
+ // (e.g. before the first copy to it); the previous frame is held.
+ tracing::debug!(id = part.id, "present_xfb: XFB copy not found in cache, skipping part");
let marker = format!("PresentXfb skip: missing part id={}", part.id);
encoder.insert_debug_marker(&marker);
continue;
diff --git a/crates/gecko/src/flipper/gx.rs b/crates/gecko/src/flipper/gx.rs
index 3759814..b13cf53 100644
--- a/crates/gecko/src/flipper/gx.rs
+++ b/crates/gecko/src/flipper/gx.rs
@@ -221,14 +221,16 @@ pub fn present_xfb<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
let build_parts = |base_addr: u32| -> Vec<XfbPart> {
let mut parts = Vec::with_capacity(sys.gx.xfb_copies.len());
- for (id, copy) in sys.gx.xfb_copies.iter().enumerate() {
+ for copy in sys.gx.xfb_copies.iter() {
if copy.dest_addr < base_addr {
continue;
}
+
let delta_bytes = (copy.dest_addr - base_addr) as u64;
if delta_bytes >= xfb_bytes {
continue;
}
+
let delta_pixels = (delta_bytes / 2) as u32;
let offset_x = delta_pixels % stride_in_pixels;
let offset_y = delta_pixels / stride_in_pixels;
@@ -248,7 +250,7 @@ pub fn present_xfb<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
}
parts.push(XfbPart {
- id: id as u32,
+ id: copy.dest_addr,
offset_x,
offset_y,
});
@@ -259,13 +261,17 @@ pub fn present_xfb<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {
let min_base = sys.gx.xfb_copies.iter().map(|c| c.dest_addr).min().unwrap_or(0);
let parts = if frame_base != 0 {
- build_parts(frame_base)
+ let mut p = build_parts(frame_base);
+ if p.is_empty() {
+ p.push(XfbPart { id: frame_base, offset_x: 0, offset_y: 0 });
+ }
+ p
} else {
build_parts(min_base)
};
if parts.is_empty() {
- tracing::debug!("present_xfb: no copy for the scanned-out buffer, holding last frame");
+ tracing::debug!("present_xfb: no XFB copies matched the frame buffer region");
sys.gx.xfb_copies.clear();
return;
}
diff --git a/crates/gecko/src/flipper/gx/bp.rs b/crates/gecko/src/flipper/gx/bp.rs
index 78b3a49..3431971 100644
--- a/crates/gecko/src/flipper/gx/bp.rs
+++ b/crates/gecko/src/flipper/gx/bp.rs
@@ -479,15 +479,18 @@ impl GraphicsProcessor {
_ => 1.0,
};
// XFB copy: queue the copy for present_xfb() to compose at vblank,
- // and tell the renderer to snapshot the EFB region now.
- let id = self.xfb_copies.len() as u32;
+ // and tell the renderer to snapshot the EFB region now. The renderer
+ // keys its snapshot textures by this id; using the destination
+ // address makes them persist per XFB buffer across frames, so present_xfb
+ // can show the buffer the VI is scanning even on frames where the game only
+ // copied the other (back) buffer.
self.xfb_copies.push(super::XfbCopy {
dest_addr,
dest_stride,
src_h,
});
renderer.exec(GxAction::CopyXfb {
- id,
+ id: dest_addr,
src_x,
src_y,
src_w,