From f373db91e68c5c9c80b8f7e40b0d7944fd13c72b Mon Sep 17 00:00:00 2001 From: supersurviveur Date: Wed, 16 Sep 2026 15:31:40 +0200 Subject: [PATCH] chore: Refactor files and fix warnings --- src/fractal/reference.rs | 15 ++++++++++++--- src/fractal/renderer.rs | 14 ++++++++++++-- src/main.rs | 11 +++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/fractal/reference.rs b/src/fractal/reference.rs index 2b118f6..dc0f63f 100644 --- a/src/fractal/reference.rs +++ b/src/fractal/reference.rs @@ -14,6 +14,7 @@ use crate::view::{Big, big_from_f64}; /// The iteration formula. Must be kept in sync with `advance_delta` and the /// `KIND_*` constants in the shader. +#[repr(u8)] #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum FractalKind { /// `z -> z^2 + c`. @@ -58,6 +59,7 @@ const REFERENCE_ESCAPE_SQ: f64 = 1.0e10; /// Compute the reference orbit `Z_0..Z_{len-1}` where `Z_0 = z0` and /// `Z_{n+1} = f(Z_n, c)` for the given `kind` (and `power`, for Multibrot), up /// to `max_iter` steps at `precision` bits. Each entry is `[re, im]` in f32. +#[allow(clippy::too_many_arguments)] pub fn compute_reference( z0_re: &Big, z0_im: &Big, @@ -205,7 +207,8 @@ mod tests { fn reference_matches_naive_f64() { let cr = Big::try_from(-0.75_f64).unwrap(); let ci = Big::try_from(0.1_f64).unwrap(); - let points = compute_set_reference(&cr, &ci, 60, 200, FractalKind::Mandelbrot, 2, (0.0, 0.0)); + let points = + compute_set_reference(&cr, &ci, 60, 200, FractalKind::Mandelbrot, 2, (0.0, 0.0)); // Independent naive f64 orbit. let (c_re, c_im) = (-0.75_f64, 0.1_f64); @@ -215,8 +218,14 @@ mod tests { // significant figures. let tol_re = 1e-4 * (1.0 + zr.abs()); let tol_im = 1e-4 * (1.0 + zi.abs()); - assert!((point[0] as f64 - zr).abs() < tol_re, "re mismatch: {point:?} vs {zr}"); - assert!((point[1] as f64 - zi).abs() < tol_im, "im mismatch: {point:?} vs {zi}"); + assert!( + (point[0] as f64 - zr).abs() < tol_re, + "re mismatch: {point:?} vs {zr}" + ); + assert!( + (point[1] as f64 - zi).abs() < tol_im, + "im mismatch: {point:?} vs {zi}" + ); let nzr = zr * zr - zi * zi + c_re; let nzi = 2.0 * zr * zi + c_im; zr = nzr; diff --git a/src/fractal/renderer.rs b/src/fractal/renderer.rs index 6922007..8e03720 100644 --- a/src/fractal/renderer.rs +++ b/src/fractal/renderer.rs @@ -508,7 +508,13 @@ impl FractalRenderer { /// Handles needed to build a standalone [`ExportRender`] off the UI thread: /// the (immutable) pipeline and its bind-group layout, plus the target /// format. Cloned so the caller can drop the render-state lock before use. - pub fn export_handles(&self) -> (wgpu::RenderPipeline, wgpu::BindGroupLayout, wgpu::TextureFormat) { + pub fn export_handles( + &self, + ) -> ( + wgpu::RenderPipeline, + wgpu::BindGroupLayout, + wgpu::TextureFormat, + ) { ( self.export_pipeline.clone(), self.bind_group_layout.clone(), @@ -825,7 +831,11 @@ impl egui_wgpu::CallbackTrait for FractalCallback { } // Both passes read the uniform buffer; refresh it once. - queue.write_buffer(&renderer.uniform_buffer, 0, bytemuck::bytes_of(&self.uniforms)); + queue.write_buffer( + &renderer.uniform_buffer, + 0, + bytemuck::bytes_of(&self.uniforms), + ); if let Some(cache) = &renderer.cache { if iter_dirty { diff --git a/src/main.rs b/src/main.rs index 1e8afef..ba6f722 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +// Without these, rust fails to infer Send/Sync trait impls +// Probably caused by the new trait solver +#![recursion_limit = "256"] + // Fractal Explorer — Rust + wgpu + egui + WGSL deep-zoom Mandelbrot. // // A single binary drives both native and web (WASM/WebGPU) builds; the two @@ -25,14 +29,13 @@ fn wgpu_options() -> eframe::egui_wgpu::WgpuConfiguration { let mut options = eframe::egui_wgpu::WgpuConfiguration::default(); if let WgpuSetup::CreateNew(setup) = &mut options.wgpu_setup { - setup.device_descriptor = std::sync::Arc::new(|adapter: &wgpu::Adapter| { - wgpu::DeviceDescriptor { + setup.device_descriptor = + std::sync::Arc::new(|adapter: &wgpu::Adapter| wgpu::DeviceDescriptor { label: Some("fractal wgpu device"), required_features: wgpu::Features::empty(), required_limits: adapter.limits(), ..Default::default() - } - }); + }); #[cfg(target_arch = "wasm32")] { setup.instance_descriptor.backends = wgpu::Backends::BROWSER_WEBGPU;