A GameCube/Wii emulator and debugger written in Rust.
asdasdasd
Layle735f1c23bd3c
diff --git a/crates/backend-wgpu/src/lib.rs b/crates/backend-wgpu/src/lib.rsindex 30fd473..373b1db 100644--- a/crates/backend-wgpu/src/lib.rs+++ b/crates/backend-wgpu/src/lib.rs@@ -6,9 +6,9 @@ mod render;pub mod sink;use encase::ShaderType as _;+use gecko::common::Address;use gecko::flipper::gx::draw::{Scissor, Viewport};use gecko::flipper::gx::regs::{AlphaCompare, BlendMode, CompareFunc, CullMode, MagFilter, MinFilter, WrapMode, ZMode};-use gecko::host::TextureId;use glam::Mat4;use pipeline::PipelineKey;use std::collections::HashMap;@@ -39,7 +39,7 @@ type SamplerKey = (WrapMode, WrapMode, MagFilter, MinFilter);#[derive(Clone, PartialEq, Eq, Hash)]pub(crate) struct BindGroupCacheKey {- tex_keys: [Option<TextureId>; 8],+ tex_keys: [Option<Address>; 8],sampler_keys: [Option<SamplerKey>; 8],}@@ -104,7 +104,7 @@ pub struct GxRenderer {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<TextureId, (wgpu::Texture, wgpu::TextureView)>,+ pub(crate) texture_cache: HashMap<Address, (wgpu::Texture, wgpu::TextureView)>,pub(crate) fallback_view: wgpu::TextureView,pub(crate) scratch_vertices: Vec<GpuVertex>,pub(crate) scratch_draws: Vec<(u32, u32)>,@@ -127,7 +127,7 @@ pub struct GxRenderer {pub(crate) current_blend_mode: BlendMode,pub(crate) current_alpha_compare: AlphaCompare,pub(crate) current_cull_mode: CullMode,- pub(crate) current_texture_ids: [Option<TextureId>; 8],+ pub(crate) current_texture_ids: [Option<Address>; 8],pub(crate) current_sampler_keys: [Option<SamplerKey>; 8],// XFB output texture: composited from per-copy snapshots by PresentXfb.pub(crate) xfb_texture: wgpu::Texture,diff --git a/crates/gecko/src/common.rs b/crates/gecko/src/common.rsnew file mode 100644index 0000000..3c43466--- /dev/null+++ b/crates/gecko/src/common.rs@@ -0,0 +1 @@+pub type Address = u32;diff --git a/crates/gecko/src/flipper/gx.rs b/crates/gecko/src/flipper/gx.rsindex f6fba6f..54a4928 100644--- a/crates/gecko/src/flipper/gx.rs+++ b/crates/gecko/src/flipper/gx.rs@@ -171,7 +171,7 @@ pub fn present_xfb(gc: &mut GameCube) {let delta_pixels = (delta_bytes / 2) as u32;let offset_x = delta_pixels % stride_in_pixels;let offset_y = delta_pixels / stride_in_pixels;-+// Real XFB copies always land at row boundaries (offset_x == 0).// A non-zero offset_x means this copy belongs to a different// buffer that happens to sit nearby in memory, reject it? TODOdiff --git a/crates/gecko/src/flipper/gx/bp.rs b/crates/gecko/src/flipper/gx/bp.rsindex 2918e4b..b006849 100644--- a/crates/gecko/src/flipper/gx/bp.rs+++ b/crates/gecko/src/flipper/gx/bp.rs@@ -12,6 +12,7 @@ use super::regs::{TevRegisterL, TxSetImage0, TxSetImage3, TxSetMode0, ZMode,};use super::{GraphicsProcessor, draw, texture};+use crate::common::Address;use crate::host::{GxAction, RenderSink};impl GraphicsProcessor {@@ -153,7 +154,6 @@ impl GraphicsProcessor {let height = (image0.height() + 1) as u32;let ram_addr = image3.ram_addr();let format = image0.format();- let id = ram_addr as TextureId;tracing::debug!(slot,@@ -180,7 +180,7 @@ impl GraphicsProcessor {min_filter: mode0.min_filter(),};renderer.exec(GxAction::LoadTexture {- id,+ id: ram_addr as Address,width,height,rgba: texture::decode_to_rgba(ram, &desc),@@ -200,7 +200,7 @@ impl GraphicsProcessor {renderer.exec(GxAction::SetTexture {slot,- id,+ id: ram_addr as Address,wrap_s: mode0.wrap_s(),wrap_t: mode0.wrap_t(),mag_filter: mode0.mag_filter(),diff --git a/crates/gecko/src/host.rs b/crates/gecko/src/host.rsindex 4ff625d..b26d1c6 100644--- a/crates/gecko/src/host.rs+++ b/crates/gecko/src/host.rs@@ -1,3 +1,4 @@+use crate::common::Address;use crate::flipper::gx::draw::{Primitive, Scissor, Viewport};use crate::flipper::gx::regs::{AlphaCompare, BlendMode, ChanCtrl, CullMode, MagFilter, MinFilter, WrapMode, ZMode};@@ -20,7 +21,7 @@ pub enum GxAction {/// Upload pre-decoded texture data. Emitted when texture content at a/// given address changes (detected by hash).LoadTexture {- id: u32,+ id: Address,width: u32,height: u32,rgba: Vec<u8>,@@ -29,7 +30,7 @@ pub enum GxAction {/// Bind a previously loaded texture to a TEV texture slot.SetTexture {slot: usize,- id: u32,+ id: Address,wrap_s: WrapMode,wrap_t: WrapMode,mag_filter: MagFilter,@@ -45,7 +46,7 @@ pub enum GxAction {/// The renderer stores this until the next [`PresentXfb`] composites it/// into the output framebuffer.CopyXfb {- id: u32,+ id: Address,src_x: u32,src_y: u32,src_w: u32,@@ -70,7 +71,7 @@ pub enum GxAction {/// are the pixel coordinates in the output framebuffer.#[derive(Debug, Clone, Copy)]pub struct XfbPart {- pub id: u32,+ pub id: Address,pub offset_x: u32,pub offset_y: u32,}diff --git a/crates/gecko/src/lib.rs b/crates/gecko/src/lib.rsindex 5dedb07..3432915 100644--- a/crates/gecko/src/lib.rs+++ b/crates/gecko/src/lib.rs@@ -1,3 +1,4 @@+pub mod common;pub mod cpu;pub mod dvd;pub mod flipper;