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
+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)
}
}