fmt clippy

This commit is contained in:
2025-12-26 01:01:55 +00:00
parent ee0e0c2b5f
commit 7c485737cd
12 changed files with 103 additions and 130 deletions
+14 -20
View File
@@ -422,14 +422,13 @@ impl App {
} else {
DEPTH_FORMAT_ORDERING.iter()
})
.filter(|format| {
.find(|format| {
physical_device
.format_properties(**format)
.unwrap()
.optimal_tiling_features
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
})
.next()
.expect("Could not find suitable depth format!");
info!("Using depth format {:?}", depth_format);
@@ -754,7 +753,6 @@ impl ApplicationHandler for App {
.surface_present_modes(&surface, Default::default())
.unwrap();
present_modes
.into_iter()
.min_by_key(|p| {
@@ -1073,7 +1071,8 @@ impl ApplicationHandler for App {
event: DeviceEvent,
) {
if let DeviceEvent::MouseMotion { delta } = &event
&& self.cstate.looking {
&& self.cstate.looking
{
self.cstate.forward.x += delta.1 as f32 * self.gstate.cursor_sensitivity * 0.3;
self.cstate.forward.y += delta.0 as f32 * self.gstate.cursor_sensitivity * 0.3;
self.cstate.forward.x += 360f32 % 360f32;
@@ -1090,8 +1089,7 @@ impl ApplicationHandler for App {
let rcx_clone = self.rcx.clone();
let mut rcx_lock = rcx_clone.lock().unwrap();
let rcx = rcx_lock.as_mut().unwrap();
if self.draw_gui
&& rcx.gui.update(&event) {
if self.draw_gui && rcx.gui.update(&event) {
return;
}
match &event {
@@ -1200,32 +1198,28 @@ impl App {
fn move_camera(&mut self) {
if self.cstate.looking {
if self.cstate.keys.w {
self.cstate.position -=
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
self.cstate.position -= Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::Z
* 0.01
* self.gstate.move_speed;
}
if self.cstate.keys.s {
self.cstate.position +=
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
self.cstate.position += Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::Z
* 0.01
* self.gstate.move_speed;
}
if self.cstate.keys.a {
self.cstate.position -=
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
self.cstate.position -= Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::X
* 0.01
* self.gstate.move_speed;
}
if self.cstate.keys.d {
self.cstate.position +=
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
self.cstate.position += Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::X
* 0.01
@@ -1504,7 +1498,7 @@ impl App {
fn add_commands_depth_pass(
&self,
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
push_constants: &Vec<PushConstantData>,
push_constants: &[PushConstantData],
trace_set: Arc<DescriptorSet>,
frame_index: usize,
) {
@@ -1545,7 +1539,7 @@ impl App {
fn add_commands_normal_pass(
&self,
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
push_constants: &Vec<PushConstantData>,
push_constants: &[PushConstantData],
normals_set1: Arc<DescriptorSet>,
normals_set2: Arc<DescriptorSet>,
frame_index: usize,
@@ -2082,8 +2076,9 @@ impl App {
match work {
WorkComplete::GetPushConstants(pc, future, index) => {
push_constants[index] = pc;
push_constant_future = if push_constant_future.is_some() {
Some(push_constant_future.unwrap().join(future).boxed())
push_constant_future =
if let Some(push_constant_future) = push_constant_future {
Some(push_constant_future.join(future).boxed())
} else {
Some(future.boxed())
};
@@ -2639,8 +2634,7 @@ where
}
fn dump_pipeline_cache(cache: Arc<PipelineCache>) {
if PIPELINE_CACHING
&& let Ok(data) = cache.get_data() {
if PIPELINE_CACHING && let Ok(data) = cache.get_data() {
info!("Dumping pipeline cache...");
let tmp_path = relpath("pipeline_cache.bin.tmp");
+1 -1
View File
@@ -37,7 +37,7 @@ impl Scene {
compute_queue: &Arc<Queue>,
memory_allocator: &Arc<dyn MemoryAllocator>,
command_buffer_allocator: &Arc<dyn CommandBufferAllocator>,
meshes: &Vec<Mesh>,
meshes: &[Mesh],
) -> Self {
// For simplicity, we build a single command buffer that builds the acceleration
// structure, then waits for its execution to complete.
+6 -18
View File
@@ -117,12 +117,8 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
let trace_shader_module =
sdf_specialize_module(device.clone(), &parts, trace_module, "trace");
let normals_shader_module = sdf_specialize_module(
device.clone(),
&parts,
normals_module,
"normals",
);
let normals_shader_module =
sdf_specialize_module(device.clone(), &parts, normals_module, "normals");
let (trace_pipeline, normals_pipeline) = deferred_pipelines_recompile(
device,
@@ -268,18 +264,10 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
) => {
let csg_start = Instant::now();
let mut csg = csg.write().unwrap();
csg.trace_shader_module = sdf_specialize_module(
device.clone(),
&csg.parts,
trace_module,
"trace",
);
csg.normals_shader_module = sdf_specialize_module(
device.clone(),
&csg.parts,
normals_module,
"normals",
);
csg.trace_shader_module =
sdf_specialize_module(device.clone(), &csg.parts, trace_module, "trace");
csg.normals_shader_module =
sdf_specialize_module(device.clone(), &csg.parts, normals_module, "normals");
(csg.trace_pipeline, csg.normals_pipeline) = deferred_pipelines_recompile(
device,
+3 -5
View File
@@ -307,16 +307,14 @@ impl<'csg> IntervalInterpreter<'csg> {
self.param_three(instruction, |d1, d2, k| {
let h = (Interval::HALF + (Interval::HALF * (d2 - d1) / k))
.clamp(Interval::ZERO, Interval::ONE);
return ((d2 * (Interval::ONE - h)) + (d1 * h))
- k * h * (Interval::ONE - h);
((d2 * (Interval::ONE - h)) + (d1 * h)) - k * h * (Interval::ONE - h)
});
},
SSASmoothMax => {
self.param_three(instruction, |d1, d2, k| {
let h = (Interval::HALF - (Interval::HALF * (d2 + d1) / k))
.clamp(Interval::ZERO, Interval::ONE);
return ((d2 * (Interval::ONE - h)) + (-d1 * h))
+ k * h * (Interval::ONE - h);
((d2 * (Interval::ONE - h)) + (-d1 * h)) + k * h * (Interval::ONE - h)
});
},
SSASmoothMinMaterial => todo!(),
@@ -394,6 +392,6 @@ impl<'csg> IntervalInterpreter<'csg> {
SSAStop => return Interval::ZERO,
}
}
return Interval::NAN;
Interval::NAN
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ pub mod point;
pub type Value = std::simd::f32x8;
pub type Mask = std::simd::mask32x8;
pub const VALUE_NAN: Value = Value::splat(core::f32::NAN);
pub const VALUE_NAN: Value = Value::splat(f32::NAN);
pub const VALUE_1: Value = Value::splat(1.0);
pub const VALUE_0: Value = Value::splat(0.0);
pub const VALUE_05: Value = Value::splat(0.5);
+4 -4
View File
@@ -211,7 +211,7 @@ impl<'csg> PointInterpreter<'csg> {
self.param_one(instruction, |val_a| val_a.ceil());
},
SSAFract => {
self.param_one(instruction, |val_a| glfract(val_a));
self.param_one(instruction, glfract);
},
SSASin => {
self.param_one(instruction, |val_a| val_a.sin());
@@ -258,14 +258,14 @@ impl<'csg> PointInterpreter<'csg> {
self.param_three(instruction, |d1, d2, k| {
let h =
(VALUE_05 + (VALUE_05 * (d2 - d1) / k)).simd_clamp(VALUE_0, VALUE_1);
return ((d2 * (VALUE_1 - h)) + (d1 * h)) - k * h * (VALUE_1 - h);
((d2 * (VALUE_1 - h)) + (d1 * h)) - k * h * (VALUE_1 - h)
});
},
SSASmoothMax => {
self.param_three(instruction, |d1, d2, k| {
let h =
(VALUE_05 - (VALUE_05 * (d2 + d1) / k)).simd_clamp(VALUE_0, VALUE_1);
return ((d2 * (VALUE_1 - h)) + (-d1 * h)) + k * h * (VALUE_1 - h);
((d2 * (VALUE_1 - h)) + (-d1 * h)) + k * h * (VALUE_1 - h)
});
},
SSASmoothMinMaterial => todo!(),
@@ -354,6 +354,6 @@ impl<'csg> PointInterpreter<'csg> {
SSAStop => return VALUE_0,
}
}
return VALUE_NAN;
VALUE_NAN
}
}
+14 -17
View File
@@ -62,7 +62,7 @@ pub(crate) fn compile_interval_function(
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32)) -> (u32, u32),
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
mapping.insert(instruction.outputs[i], func(b, val_a));
}
}
@@ -75,11 +75,11 @@ pub(crate) fn compile_interval_function(
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32), (u32, u32)) -> (u32, u32),
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
let val_b = input_resolve(
float,
b,
&mapping,
mapping,
instruction.inputs[i + instruction.opcode.size as usize],
);
mapping.insert(instruction.outputs[i], func(b, val_a, val_b));
@@ -94,17 +94,17 @@ pub(crate) fn compile_interval_function(
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32), (u32, u32), (u32, u32)) -> (u32, u32),
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
let val_b = input_resolve(
float,
b,
&mapping,
mapping,
instruction.inputs[i + instruction.opcode.size as usize],
);
let val_c = input_resolve(
float,
b,
&mapping,
mapping,
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
);
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c));
@@ -299,7 +299,7 @@ pub(crate) fn compile_interval_function(
bool: u32,
glsl: u32,
opcode_size: u8,
val_a: &Vec<(u32, u32)>,
val_a: &[(u32, u32)],
) -> (u32, u32) {
let zero_const = b.constant_bit32(float, (0.0f32).to_bits());
let val_a_lowers = val_a
@@ -1001,8 +1001,7 @@ pub(crate) fn compile_interval_function(
let muly = multiply(types.float, b, types.glsl, val_a[1], val_b[1]);
let mulz = multiply(types.float, b, types.glsl, val_a[2], val_b[2]);
let accum = add(types.float, b, mulx, muly);
let accum = add(types.float, b, accum, mulz);
accum
add(types.float, b, accum, mulz)
},
4 => {
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
@@ -1011,8 +1010,7 @@ pub(crate) fn compile_interval_function(
let mulw = multiply(types.float, b, types.glsl, val_a[3], val_b[3]);
let accum = add(types.float, b, mulx, muly);
let accum = add(types.float, b, accum, mulz);
let accum = add(types.float, b, accum, mulw);
accum
add(types.float, b, accum, mulw)
},
_ => unreachable!("Invalid opcode size {}", instruction.opcode.size),
};
@@ -1625,8 +1623,7 @@ pub(crate) fn compile_interval_function(
})
.collect::<Vec<_>>();
let radius =
input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
let radius = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
let length = length(types.float, b, types.bool, types.glsl, 3, &pos_part);
let sphere = sub(types.float, b, length, radius);
@@ -1690,7 +1687,7 @@ pub(crate) fn compile_interval_function(
types.bool,
types.glsl,
3,
&vec![qx_limit, qy_limit, qz_limit],
&[qx_limit, qy_limit, qz_limit],
);
let max1 =
@@ -1725,8 +1722,8 @@ pub(crate) fn compile_interval_function(
})
.collect::<Vec<_>>();
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4 as usize]);
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4_usize]);
let squ1 = square(types.float, b, types.bool, types.glsl, pos_part[0]);
let squ2 = square(types.float, b, types.bool, types.glsl, pos_part[2]);
@@ -1757,7 +1754,7 @@ pub(crate) fn compile_interval_function(
types.bool,
types.glsl,
2,
&vec![subtx, pos_part[1]],
&[subtx, pos_part[1]],
);
mapping.insert(instruction.outputs[0], sub(types.float, b, length, rad2));
+11 -14
View File
@@ -57,7 +57,7 @@ pub(crate) fn compile_point_function(
func: impl Fn(&mut rspirv::dr::Builder, u32) -> u32,
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
mapping.insert(instruction.outputs[i], func(b, val_a));
}
}
@@ -70,11 +70,11 @@ pub(crate) fn compile_point_function(
func: impl Fn(&mut rspirv::dr::Builder, u32, u32) -> u32,
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
let val_b = input_resolve(
float,
b,
&mapping,
mapping,
instruction.inputs[i + instruction.opcode.size as usize],
);
mapping.insert(instruction.outputs[i], func(b, val_a, val_b));
@@ -89,17 +89,17 @@ pub(crate) fn compile_point_function(
func: impl Fn(&mut rspirv::dr::Builder, u32, u32, u32) -> u32,
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
let val_b = input_resolve(
float,
b,
&mapping,
mapping,
instruction.inputs[i + instruction.opcode.size as usize],
);
let val_c = input_resolve(
float,
b,
&mapping,
mapping,
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
);
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c));
@@ -629,8 +629,7 @@ pub(crate) fn compile_point_function(
.collect::<Vec<_>>();
let pos = b.composite_construct(types.vec3, None, pos_part).unwrap();
let radius =
input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
let radius = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
let length = b
.ext_inst(
@@ -745,8 +744,8 @@ pub(crate) fn compile_point_function(
.composite_construct(types.vec2, None, [pos_part[0], pos_part[2]])
.unwrap();
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4 as usize]);
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4_usize]);
let dot = b.dot(types.float, None, pos_vec2, pos_vec2).unwrap();
let sqrt = b
@@ -798,10 +797,8 @@ pub(crate) fn compile_point_function(
let select_less = b.select(types.float, None, less, onen, nan).unwrap();
let select_more =
b.select(types.float, None, more, one, select_less).unwrap();
let select_eq = b
.select(types.float, None, equal, zero, select_more)
.unwrap();
select_eq
b.select(types.float, None, equal, zero, select_more)
.unwrap()
},
);
},
+6 -7
View File
@@ -158,7 +158,7 @@ impl SSAOpcodeSized {
}
}
const fn to_raw_opcode(&self) -> GPUOpcode {
const fn to_raw_opcode(self) -> GPUOpcode {
use InstructionSet::*;
use SSAOpcode::*;
const fn opcode_drop(inst: InstructionSet, width: u8) -> GPUOpcode {
@@ -258,7 +258,7 @@ impl SSATape {
inputs,
outputs,
});
return outputs_register;
outputs_register
}
pub fn compile_to_gpu(&self) -> GPUTape {
@@ -500,21 +500,21 @@ impl SSATape {
compile_point_function(
&mut b,
&self,
self,
types,
if with_module { Some(1000) } else { None },
);
compile_interval_function(
&mut b,
&self,
self,
types,
if with_module { Some(2000) } else { None },
);
//compile_gradient_function(
// &mut b,
// &self,
// self,
// types,
// if with_module { Some(3000) } else { None },
//);
@@ -526,8 +526,7 @@ impl SSATape {
format!(
"{}.spv-dis",
humantime::format_rfc3339(std::time::SystemTime::now())
)
.to_string(),
),
module.disassemble(),
)
.unwrap();
+1 -1
View File
@@ -35,7 +35,7 @@ impl std::fmt::Debug for Interval {
impl Interval {
pub const HALF: Self = Self::const_splat(0.5);
pub const MONE: Self = Self::const_splat(-1.0);
pub const NAN: Self = Self::const_splat(core::f32::NAN);
pub const NAN: Self = Self::const_splat(f32::NAN);
pub const ONE: Self = Self::const_splat(1.0);
pub const PI: Self = Self::const_splat(core::f32::consts::PI);
pub const PI_2: Self = Self::const_splat(core::f32::consts::FRAC_PI_2);
+1 -1
View File
@@ -86,6 +86,6 @@ impl std::ops::Not for VChoice {
impl std::ops::BitAndAssign<VChoice> for VChoice {
fn bitand_assign(&mut self, other: Self) {
self.0 = (self.0) | ((!other.0) & u32x8::splat(3))
self.0 |= (!other.0) & u32x8::splat(3)
}
}