A GameCube/Wii emulator and debugger written in Rust.
fxhash
Layled11388a76349
diff --git a/Cargo.lock b/Cargo.lockindex ec4d6b2..fc46eef 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -236,6 +236,7 @@ dependencies = ["encase","gecko","glam",+ "rustc-hash 2.1.2","tracing","wesl","wgpu",@@ -1276,6 +1277,8 @@ dependencies = ["crossbeam-channel","glam","image 0.1.0",+ "multiversion",+ "rustc-hash 2.1.2","tracing","twox-hash",]@@ -1538,7 +1541,7 @@ dependencies = ["num_enum","ron","rstest",- "rustc-hash 2.1.1",+ "rustc-hash 2.1.2","serde","zstd",]@@ -2041,7 +2044,7 @@ dependencies = ["mlua-sys","num-traits","parking_lot",- "rustc-hash 2.1.1",+ "rustc-hash 2.1.2","rustversion",]@@ -2069,6 +2072,28 @@ dependencies = ["pxfm",]+[[package]]+name = "multiversion"+version = "0.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7edb7f0ff51249dfda9ab96b5823695e15a052dc15074c9dbf3d118afaf2c201"+dependencies = [+ "multiversion-macros",+ "target-features",+]++[[package]]+name = "multiversion-macros"+version = "0.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b093064383341eb3271f42e381cb8f10a01459478446953953c75d24bd339fc0"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+ "target-features",+]+[[package]]name = "naga"version = "28.0.0"@@ -2925,9 +2950,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"[[package]]name = "rustc-hash"-version = "2.1.1"+version = "2.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"+checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe"[[package]]name = "rustc_version"@@ -3287,6 +3312,12 @@ dependencies = ["syn",]+[[package]]+name = "target-features"+version = "0.1.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5"+[[package]]name = "term"version = "1.2.1"@@ -3586,7 +3617,7 @@ version = "0.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90"dependencies = [- "rustc-hash 2.1.1",+ "rustc-hash 2.1.2",][[package]]diff --git a/crates/backend-wgpu/Cargo.toml b/crates/backend-wgpu/Cargo.tomlindex 9cd68e7..d2e8e75 100644--- a/crates/backend-wgpu/Cargo.toml+++ b/crates/backend-wgpu/Cargo.toml@@ -15,6 +15,7 @@ encase = "0.12.0"glam = { version = "0.32.1", features = ["encase"] }crossbeam-channel = "0.5.15"tracing = "0.1.44"+rustc-hash = "2.1.2"[build-dependencies]wesl = "0.3.2"diff --git a/crates/backend-wgpu/src/lib.rs b/crates/backend-wgpu/src/lib.rsindex b25e0ec..7d0b611 100644--- a/crates/backend-wgpu/src/lib.rs+++ b/crates/backend-wgpu/src/lib.rs@@ -13,7 +13,7 @@ use gecko::flipper::gx::regs::{AlphaCompare, BlendMode, CompareFunc, CullMode, Muse gecko::host::EfbWriteback;use glam::Mat4;use pipeline::PipelineKey;-use std::collections::HashMap;+use rustc_hash::FxHashMap;#[repr(C)]#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]@@ -85,7 +85,7 @@ pub const EFB_HEIGHT: u32 = 528;pub const EFB_SAMPLE_COUNT: u32 = 4;pub struct GxRenderer {- pub(crate) pipeline_cache: HashMap<PipelineKey, wgpu::RenderPipeline>,+ pub(crate) pipeline_cache: FxHashMap<PipelineKey, wgpu::RenderPipeline>,pub(crate) shader: wgpu::ShaderModule,pub(crate) pipeline_layout: wgpu::PipelineLayout,pub(crate) surface_format: wgpu::TextureFormat,@@ -105,13 +105,13 @@ pub struct GxRenderer {// EFB: multisampled (4x) depth.pub(crate) efb_depth_view: wgpu::TextureView,pub(crate) efb_needs_clear: bool,- pub(crate) sampler_cache: HashMap<(WrapMode, WrapMode, MagFilter, MinFilter), wgpu::Sampler>,- pub(crate) texture_cache: HashMap<Address, (wgpu::Texture, wgpu::TextureView)>,+ pub(crate) sampler_cache: FxHashMap<(WrapMode, WrapMode, MagFilter, MinFilter), wgpu::Sampler>,+ pub(crate) texture_cache: FxHashMap<Address, (wgpu::Texture, wgpu::TextureView)>,pub(crate) fallback_view: wgpu::TextureView,pub(crate) scratch_vertices: Vec<GpuVertex>,pub(crate) scratch_draws: Vec<(u32, u32)>,pub(crate) scratch_uniform_bytes: Vec<u8>,- pub(crate) bind_group_cache: HashMap<BindGroupCacheKey, wgpu::BindGroup>,+ pub(crate) bind_group_cache: FxHashMap<BindGroupCacheKey, wgpu::BindGroup>,// Per-frame draw accumulation (persists across process_action calls,// flushed by flush_pending_draws).pub(crate) frame_uniform_bytes: Vec<u8>,@@ -136,7 +136,7 @@ pub struct GxRenderer {pub xfb_view: wgpu::TextureView,pub(crate) xfb_has_content: bool,// Per-copy temporary textures stored by CopyXfb, composited by PresentXfb.- pub(crate) xfb_copies: HashMap<u32, (wgpu::Texture, wgpu::TextureView)>,+ pub(crate) xfb_copies: FxHashMap<u32, (wgpu::Texture, wgpu::TextureView)>,// Region-scoped EFB clear.pub(crate) efb_clear: clear::EfbClear,// EFB-to-texture readback. Only allocated with `efb-writeback`.@@ -361,7 +361,7 @@ impl GxRenderer {);GxRenderer {- pipeline_cache: HashMap::new(),+ pipeline_cache: FxHashMap::default(),shader,pipeline_layout,surface_format,@@ -378,16 +378,20 @@ impl GxRenderer {efb_msaa_view,efb_depth_view,efb_needs_clear: true,- sampler_cache: HashMap::from([(- (WrapMode::Clamp, WrapMode::Clamp, MagFilter::Linear, MinFilter::Linear),- sampler,- )]),- texture_cache: HashMap::new(),+ sampler_cache: {+ let mut m = FxHashMap::default();+ m.insert(+ (WrapMode::Clamp, WrapMode::Clamp, MagFilter::Linear, MinFilter::Linear),+ sampler,+ );+ m+ },+ texture_cache: FxHashMap::default(),fallback_view,scratch_vertices: Vec::new(),scratch_draws: Vec::new(),scratch_uniform_bytes: Vec::new(),- bind_group_cache: HashMap::new(),+ bind_group_cache: FxHashMap::default(),frame_uniform_bytes: Vec::new(),draw_pipeline_keys: Vec::new(),draw_bg_keys: Vec::new(),@@ -412,7 +416,7 @@ impl GxRenderer {xfb_texture,xfb_view,xfb_has_content: false,- xfb_copies: HashMap::new(),+ xfb_copies: FxHashMap::default(),efb_clear,#[cfg(feature = "efb-writeback")]efb_readback_staging: None,diff --git a/crates/gecko/Cargo.toml b/crates/gecko/Cargo.tomlindex 41fdcd0..2f375eb 100644--- a/crates/gecko/Cargo.toml+++ b/crates/gecko/Cargo.toml@@ -25,3 +25,4 @@ bytemuck = { version = "1.25.0", features = ["derive"] }twox-hash = "2.1.2"crossbeam-channel = { version = "0.5.15", optional = true }multiversion = "0.8.0"+rustc-hash = "2.1.2"diff --git a/crates/gecko/src/flipper/gx.rs b/crates/gecko/src/flipper/gx.rsindex 72535e2..b7ce65f 100644--- a/crates/gecko/src/flipper/gx.rs+++ b/crates/gecko/src/flipper/gx.rs@@ -19,7 +19,7 @@ use crate::host::EfbWriteback;use crate::host::{GxAction, RenderSink, XfbPart};use crate::mmio::Mmio;use fifo::FifoCmd;-use std::collections::HashMap;+use rustc_hash::FxHashMap;pub struct GraphicsProcessor {pub raise_interrupt: bool,@@ -58,7 +58,7 @@ pub struct GraphicsProcessor {pub xfb_copies: Vec<XfbCopy>,// Hash of the raw texture data at each RAM address; used to detect when// texture content changes and avoid redundant decodes + LoadTexture sends.- pub texture_hashes: HashMap<u32, u64>,+ pub texture_hashes: FxHashMap<u32, u64>,// Receiver for encoded EFB-to-texture bytes coming back from the// renderer worker. `efb_copy` drains this synchronously right after// emitting the copy action, so the next FIFO command in the same burst@@ -105,7 +105,7 @@ impl GraphicsProcessor {cur_scissor_offset_x: 0,cur_scissor_offset_y: 0,xfb_copies: Vec::new(),- texture_hashes: HashMap::new(),+ texture_hashes: FxHashMap::default(),#[cfg(feature = "efb-writeback")]efb_writeback_rx: None,}diff --git a/crates/gecko/src/flipper/gx/bp.rs b/crates/gecko/src/flipper/gx/bp.rsindex 7540046..7e8a20c 100644--- a/crates/gecko/src/flipper/gx/bp.rs+++ b/crates/gecko/src/flipper/gx/bp.rs@@ -436,7 +436,7 @@ impl GraphicsProcessor {/// Returns `true` when the raw texture data in RAM differs from the last/// hash recorded for the given address.fn texture_data_changed(- hashes: &mut std::collections::HashMap<u32, u64>,+ hashes: &mut rustc_hash::FxHashMap<u32, u64>,ram: &[u8],addr: usize,width: u32,