Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

fix Z16 depth texture byte order and far-plane clamp, thanks liy!

Layle569ed6976a36
diff --git a/crates/backend-wgpu/src/shaders/efb_depth.wgsl b/crates/backend-wgpu/src/shaders/efb_depth.wgsl
index 18c0f6b..000648c 100644
--- a/crates/backend-wgpu/src/shaders/efb_depth.wgsl
+++ b/crates/backend-wgpu/src/shaders/efb_depth.wgsl
@@ -39,7 +39,7 @@ fn fs_writeback_z24(@builtin(position) position: vec4<f32>) -> @location(0) vec4
let src_pixel = u.src_rect.xy + (position.xy / dst_size) * u.src_rect.zw;
let coord = vec2<i32>(src_pixel);
let depth = textureLoad(efb_depth, coord, 0);
- let z24 = u32(depth * Z24_SCALE);
+ let z24 = min(u32(depth * Z24_SCALE), 0xFFFFFFu);
let r = f32((z24 >> 16u) & 0xFFu) / 255.0;
let g = f32((z24 >> 8u) & 0xFFu) / 255.0;
let b = f32( z24 & 0xFFu) / 255.0;
diff --git a/crates/gecko/src/flipper/gx/texture.rs b/crates/gecko/src/flipper/gx/texture.rs
index 3a2d9ab..83a50f3 100644
--- a/crates/gecko/src/flipper/gx/texture.rs
+++ b/crates/gecko/src/flipper/gx/texture.rs
@@ -1099,7 +1099,7 @@ fn encode_rg8(rgba: &[u8], out: &mut [u8], w: usize, h: usize) {
unsafe {
let s = ((base_y + ty) * w + base_x + tx) * 4;
let off = blk + (ty * BW + tx) * 2;
- std::ptr::write(dst.add(off).cast::<[u8; 2]>(), [*src.add(s), *src.add(s + 1)]);
+ std::ptr::write(dst.add(off).cast::<[u8; 2]>(), [*src.add(s + 1), *src.add(s)]);
}
}
}