Skip to content

Commit 003366f

Browse files
committed
fmt
1 parent cc2c3f9 commit 003366f

39 files changed

+122
-172
lines changed

DEVLOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ My setup is like this:
184184

185185
All together this lets me know if my shader validates after each change.
186186

187+
#### Solution
188+
189+
As it turns out `Transform`'s `From<Mat4>` was the culprit. It was using `Mat4::to_scale_rotation_translation`,
190+
which calls `f32::signum`, which uses `NAN`.
191+
192+
The crappy part is that `clippy` would have caught it, because both of those functions are listed in `disallowed-methods`,
193+
but I hardly ever _run_ clippy. So now I've got to make that a normal practice.
194+
187195
## Wed May 8, 2024
188196

189197
TODO: `crabslab` probably doesn't need to generate the `offset_of_*` functions. It's a bit noisy,

crates/example/src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ impl App {
319319
// r.graph.add_resource(scene);
320320
// self.loader = None;
321321
// self.ui
322-
// .set_text_title("awaiting drag and dropped `.gltf` or `.glb` file");
323-
// }
322+
// .set_text_title("awaiting drag and dropped `.gltf` or `.glb`
323+
// file"); }
324324
// _ => {}
325325
// };
326326
// }
@@ -391,17 +391,17 @@ impl App {
391391
// match ev {
392392
// winit::event::WindowEvent::MouseWheel { delta, .. } => {
393393
// let delta = match delta {
394-
// winit::event::MouseScrollDelta::LineDelta(_, up) => *up,
395-
// winit::event::MouseScrollDelta::PixelDelta(pos) => pos.y as f32,
396-
// };
394+
// winit::event::MouseScrollDelta::LineDelta(_, up) =>
395+
// *up, winit::event::MouseScrollDelta::PixelDelta(pos)
396+
// => pos.y as f32, };
397397

398398
// app.zoom(r, delta);
399399
// }
400400
// winit::event::WindowEvent::CursorMoved { position, .. } => {
401401
// app.pan(r, *position);
402402
// }
403-
// winit::event::WindowEvent::MouseInput { state, button, .. } => {
404-
// app.mouse_button(*state, *button);
403+
// winit::event::WindowEvent::MouseInput { state, button, .. }
404+
// => { app.mouse_button(*state, *button);
405405
// }
406406
// winit::event::WindowEvent::KeyboardInput { input, .. } => {
407407
// app.key_input(r, *input);
@@ -418,19 +418,19 @@ impl App {
418418
// .unwrap();
419419
// }
420420
// winit::event::WindowEvent::DroppedFile(path) => {
421-
// log::trace!("got dropped file event: {}", path.display());
422-
// let path = format!("{}", path.display());
423-
// app.load(&path);
421+
// log::trace!("got dropped file event: {}",
422+
// path.display()); let path = format!("{}",
423+
// path.display()); app.load(&path);
424424
// }
425425
// _ => {}
426426
// }
427427

428428
// if let Some(ev) = event_state.event_from_winit(ev) {
429-
// let scene = r.graph.get_resource_mut::<Scene>().unwrap().unwrap();
430-
// let channel = scene.get_debug_channel();
431-
// let mut set_debug_channel = |mode| {
432-
// log::debug!("setting debug mode to {mode:?}");
433-
// if channel != mode {
429+
// let scene =
430+
// r.graph.get_resource_mut::<Scene>().unwrap().unwrap(); let
431+
// channel = scene.get_debug_channel(); let mut
432+
// set_debug_channel = |mode| { log::debug!("setting debug
433+
// mode to {mode:?}"); if channel != mode {
434434
// scene.set_debug_channel(mode);
435435
// } else {
436436
// scene.set_debug_channel(DebugChannel::None);
@@ -440,8 +440,8 @@ impl App {
440440
// match app.ui.event(ev) {
441441
// None => {}
442442
// Some(ev) => match ev {
443-
// UiEvent::ToggleDebugChannel(channel) => set_debug_channel(channel),
444-
// },
443+
// UiEvent::ToggleDebugChannel(channel) =>
444+
// set_debug_channel(channel), },
445445
// }
446446
// }
447447
// } else {

crates/example/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ pub fn tick(app: &mut App, ev: Option<&winit::event::WindowEvent>) {
136136
// match app.ui.event(ev) {
137137
// None => {}
138138
// Some(ev) => match ev {
139-
// UiEvent::ToggleDebugChannel(channel) => set_debug_channel(channel),
140-
// },
139+
// UiEvent::ToggleDebugChannel(channel) =>
140+
// set_debug_channel(channel), },
141141
// }
142142
// }
143143

crates/renderling/benches/benchmarks.rs

Lines changed: 0 additions & 61 deletions
This file was deleted.

crates/renderling/src/atlas.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ impl core::fmt::Display for TextureAddressMode {
116116
}
117117

118118
impl TextureAddressMode {
119-
/// Wrap the given s/t coord into a pixel index according to texture addressing.
119+
/// Wrap the given s/t coord into a pixel index according to texture
120+
/// addressing.
120121
pub fn wrap(&self, input: f32) -> f32 {
121122
match self {
122123
TextureAddressMode::Repeat => {

crates/renderling/src/bloom/cpu.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ impl Bloom {
422422
let downsample_pipeline = Arc::new(create_bloom_downsample_pipeline(&device));
423423
let upsample_pipeline = Arc::new(create_bloom_upsample_pipeline(&device));
424424

425-
// up and downsample pipelines have the same layout, so we just choose one for the layout
425+
// up and downsample pipelines have the same layout, so we just choose one for
426+
// the layout
426427
let bindgroups = create_bindgroups(&device, &downsample_pipeline, &slab_buffer, &textures);
427428
let hdr_texture_downsample_bindgroup = create_bindgroup(
428429
&device,
@@ -491,7 +492,8 @@ impl Bloom {
491492

492493
/// Returns a clone of the current mix texture.
493494
///
494-
/// The mix texture is the result of mixing the bloom by the hdr using the mix strength.
495+
/// The mix texture is the result of mixing the bloom by the hdr using the
496+
/// mix strength.
495497
pub fn get_mix_texture(&self) -> Texture {
496498
// UNWRAP: not safe but we want to panic
497499
self.mix_texture.read().unwrap().clone()
@@ -505,9 +507,9 @@ impl Bloom {
505507
}
506508
// Get all the bindgroups (which are what we're reading from),
507509
// starting with the hdr frame.
508-
// Since `bindgroups` are one element greater (we pushed `hdr_texture_bindgroup` to the
509-
// front) the last bindgroup will not be used, which is good - we don't need to read from
510-
// the smallest texture during downsampling.
510+
// Since `bindgroups` are one element greater (we pushed `hdr_texture_bindgroup`
511+
// to the front) the last bindgroup will not be used, which is good - we
512+
// don't need to read from the smallest texture during downsampling.
511513
// UNWRAP: not safe but we want to panic
512514
let textures_guard = self.textures.read().unwrap();
513515
let hdr_texture_downsample_bindgroup_guard =

crates/renderling/src/context.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ pub(crate) fn conduct_clear_pass<'a>(
439439

440440
/// Contains the adapter, device, queue and [`RenderTarget`].
441441
///
442-
/// A `Context` is created to initialize rendering to a window, canvas or texture.
442+
/// A `Context` is created to initialize rendering to a window, canvas or
443+
/// texture.
443444
///
444445
/// ```
445446
/// use renderling::Context;
@@ -500,8 +501,8 @@ impl Context {
500501
}
501502

502503
#[cfg(all(feature = "winit", not(target_arch = "wasm32")))]
503-
/// Create a new context from a `winit::window::Window`, blocking until it is
504-
/// created.
504+
/// Create a new context from a `winit::window::Window`, blocking until it
505+
/// is created.
505506
///
506507
/// ## Panics
507508
/// Panics if the context cannot be created.
@@ -602,12 +603,14 @@ impl Context {
602603

603604
/// Get the next frame from the render target.
604605
///
605-
/// A surface context (window or canvas) will return the next swapchain texture.
606+
/// A surface context (window or canvas) will return the next swapchain
607+
/// texture.
606608
///
607609
/// A headless context will return the underlying headless texture.
608610
///
609611
/// Errs if the render target is a surface and there was an error getting
610-
/// the next swapchain texture. This can happen if the frame has already been acquired.
612+
/// the next swapchain texture. This can happen if the frame has already
613+
/// been acquired.
611614
pub fn get_next_frame(&self) -> Result<Frame, ContextError> {
612615
Ok(Frame {
613616
device: self.device.clone(),

crates/renderling/src/lib.rs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
//! ```
2727
//!
2828
//! The stage is neat in that it allows you to place values and arrays of values
29-
//! directly onto the GPU. Those values can be modified on the CPU and synchronization
30-
//! will happen during [`Stage::render`](crate::stage::Stage::render).
31-
//! These values are called [`Hybrid`](crate::slab::Hybrid)s and [`HybridArray`](crate::slab::HybridArray)s.
29+
//! directly onto the GPU. Those values can be modified on the CPU and
30+
//! synchronization will happen during
31+
//! [`Stage::render`](crate::stage::Stage::render). These values are called
32+
//! [`Hybrid`](crate::slab::Hybrid)s and
33+
//! [`HybridArray`](crate::slab::HybridArray)s.
3234
//!
3335
//! ```
3436
//! # use renderling::{Context, stage::Stage};
@@ -38,24 +40,26 @@
3840
//!
3941
//! let an_f32: Hybrid<f32> = stage.new_value(1337.0);
4042
//!
41-
//! let an_array_of_tuples: HybridArray<(f32, u32, bool)> = stage.new_array([
42-
//! (0.0, 0, false),
43-
//! (1.0, 1, true),
44-
//! ]);
43+
//! let an_array_of_tuples: HybridArray<(f32, u32, bool)> =
44+
//! stage.new_array([(0.0, 0, false), (1.0, 1, true)]);
4545
//! ```
4646
//!
47-
//! In order to render, we need to "stage" a [`Renderlet`](crate::stage::Renderlet),
48-
//! which is a bundle of rendering resources.
49-
//! We do this in the same way we "staged" `an_f32` above.
47+
//! In order to render, we need to "stage" a
48+
//! [`Renderlet`](crate::stage::Renderlet), which is a bundle of rendering
49+
//! resources. We do this in the same way we "staged" `an_f32` above.
5050
//!
51-
//! But first we'll need a [`Camera`](crate::camera::Camera) and some vertices of
52-
//! [`Vertex`](crate::stage::Vertex) organized as triangles with counter-clockwise winding.
51+
//! But first we'll need a [`Camera`](crate::camera::Camera) and some vertices
52+
//! of [`Vertex`](crate::stage::Vertex) organized as triangles with
53+
//! counter-clockwise winding.
5354
//!
5455
//! ```
5556
//! # use renderling::{Context, stage::Stage};
5657
//! # let ctx = Context::headless(100, 100);
5758
//! # let mut stage: Stage = ctx.new_stage();
58-
//! use renderling::{camera::Camera, stage::{Renderlet, Vertex}};
59+
//! use renderling::{
60+
//! camera::Camera,
61+
//! stage::{Renderlet, Vertex},
62+
//! };
5963
//! let camera = stage.new_value(Camera::default_ortho2d(100.0, 100.0));
6064
//! let vertices = stage.new_array([
6165
//! Vertex::default()
@@ -75,20 +79,21 @@
7579
//! });
7680
//! ```
7781
//!
78-
//! This gives us `triangle`, which is a `Hybrid<Renderlet>`. We can now pass `triangle`
79-
//! to the stage to draw each frame using
82+
//! This gives us `triangle`, which is a `Hybrid<Renderlet>`. We can now pass
83+
//! `triangle` to the stage to draw each frame using
8084
//! [`Stage::add_renderlet`](crate::stage::Stage::add_renderlet).
8185
//!
82-
//! Finally, we get the next frame from the context with [`Context::get_next_frame`],
83-
//! render to it using [`Stage::render`](crate::stage::Stage::render) and then present the
86+
//! Finally, we get the next frame from the context with
87+
//! [`Context::get_next_frame`], render to it using
88+
//! [`Stage::render`](crate::stage::Stage::render) and then present the
8489
//! frame with [`Frame::present`].
8590
//!
8691
//! ```
8792
//! # use renderling::{
8893
//! # Context,
89-
//! # camera::Camera,
94+
//! # camera::Camera,
9095
//! # stage::{
91-
//! # Vertex,
96+
//! # Vertex,
9297
//! # Renderlet,
9398
//! # }
9499
//! # };
@@ -132,6 +137,7 @@
132137
//! PRs, criticisms and ideas are all very much welcomed [at the repo](https://github.com/schell/renderling).
133138
//!
134139
//! 😀☕
140+
#![allow(unexpected_cfgs)]
135141
#![cfg_attr(target_arch = "spirv", no_std)]
136142
#![deny(clippy::disallowed_methods)]
137143

@@ -853,7 +859,8 @@ mod test {
853859
}
854860

855861
#[test]
856-
// shows how to "nest" children to make them appear transformed by their parent's transform
862+
// shows how to "nest" children to make them appear transformed by their
863+
// parent's transform
857864
fn scene_parent_sanity() {
858865
let ctx = Context::headless(100, 100);
859866
let mut stage = ctx.new_stage().with_background_color(Vec4::splat(0.0));

crates/renderling/src/linkage/bloom_downsample_fragment.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#![allow(dead_code)]
32
//! Automatically generated with `cd shaders && cargo run --release`.
43
//!

crates/renderling/src/linkage/bloom_mix_fragment.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#![allow(dead_code)]
32
//! Automatically generated with `cd shaders && cargo run --release`.
43
//!

0 commit comments

Comments
 (0)