implement more intervals

This commit is contained in:
2025-12-20 23:15:37 +00:00
parent ab79317262
commit 95cb56caf5
3 changed files with 1893 additions and 1476 deletions
+517 -100
View File
@@ -90,12 +90,7 @@ pub(crate) fn compile_interval_function(
b: &mut rspirv::dr::Builder,
mapping: &mut HashMap<u32, (u32, u32)>,
instruction: &SSAInstruction,
func: impl Fn(
&mut rspirv::dr::Builder,
(u32, u32),
(u32, u32),
(u32, u32),
) -> (u32, u32),
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]);
@@ -324,14 +319,30 @@ pub(crate) fn compile_interval_function(
b.ret_value(value_vec2).unwrap();
},
SSAPosition => {
let pos_low_x = b.composite_extract(types.float, None, pos_low, [0]).unwrap();
let pos_low_y = b.composite_extract(types.float, None, pos_low, [1]).unwrap();
let pos_low_z = b.composite_extract(types.float, None, pos_low, [2]).unwrap();
let pos_low_w = b.composite_extract(types.float, None, pos_low, [3]).unwrap();
let pos_high_x = b.composite_extract(types.float, None, pos_high, [0]).unwrap();
let pos_high_y = b.composite_extract(types.float, None, pos_high, [1]).unwrap();
let pos_high_z = b.composite_extract(types.float, None, pos_high, [2]).unwrap();
let pos_high_w = b.composite_extract(types.float, None, pos_high, [3]).unwrap();
let pos_low_x = b
.composite_extract(types.float, None, pos_low, [0])
.unwrap();
let pos_low_y = b
.composite_extract(types.float, None, pos_low, [1])
.unwrap();
let pos_low_z = b
.composite_extract(types.float, None, pos_low, [2])
.unwrap();
let pos_low_w = b
.composite_extract(types.float, None, pos_low, [3])
.unwrap();
let pos_high_x = b
.composite_extract(types.float, None, pos_high, [0])
.unwrap();
let pos_high_y = b
.composite_extract(types.float, None, pos_high, [1])
.unwrap();
let pos_high_z = b
.composite_extract(types.float, None, pos_high, [2])
.unwrap();
let pos_high_w = b
.composite_extract(types.float, None, pos_high, [3])
.unwrap();
mapping.insert(instruction.outputs[0], (pos_low_x, pos_high_x));
mapping.insert(instruction.outputs[1], (pos_low_y, pos_high_y));
mapping.insert(instruction.outputs[2], (pos_low_z, pos_high_z));
@@ -410,13 +421,16 @@ pub(crate) fn compile_interval_function(
b.f_ord_not_equal(types.bool, None, v1, v1_floor).unwrap();
let v2_floor_eq =
b.f_ord_equal(types.bool, None, v1_floor, v2_floor).unwrap();
let floors =
b.logical_and(types.bool, None, v1_floor_eq, v2_floor_eq).unwrap();
let final_bool =
b.logical_and(types.bool, None, other_constant, floors).unwrap();
let floors = b
.logical_and(types.bool, None, v1_floor_eq, v2_floor_eq)
.unwrap();
let final_bool = b
.logical_and(types.bool, None, other_constant, floors)
.unwrap();
let llt =
b.f_ord_less_than(types.bool, None, val_b.0, zero_const).unwrap();
let llt = b
.f_ord_less_than(types.bool, None, val_b.0, zero_const)
.unwrap();
let ugt = b
.f_ord_greater_than(types.bool, None, val_b.1, zero_const)
.unwrap();
@@ -473,7 +487,8 @@ pub(crate) fn compile_interval_function(
&mut mapping,
instruction,
|b, val_a, val_b| {
let pi_const = b.constant_bit32(types.float, (std::f32::consts::PI).to_bits());
let pi_const =
b.constant_bit32(types.float, (std::f32::consts::PI).to_bits());
let npi_const =
b.constant_bit32(types.float, (-std::f32::consts::PI).to_bits());
(npi_const, pi_const)
@@ -632,8 +647,12 @@ pub(crate) fn compile_interval_function(
let val_a_lowers = val_a
.iter()
.map(|v| {
let lt = b.f_ord_less_than(types.bool, None, v.0, zero_const).unwrap();
let gt = b.f_ord_greater_than(types.bool, None, v.1, zero_const).unwrap();
let lt = b
.f_ord_less_than(types.bool, None, v.0, zero_const)
.unwrap();
let gt = b
.f_ord_greater_than(types.bool, None, v.1, zero_const)
.unwrap();
let both = b.logical_and(types.bool, None, lt, gt).unwrap();
let abs_l = b
.ext_inst(
@@ -746,7 +765,12 @@ pub(crate) fn compile_interval_function(
.f_mul(types.float, None, val_a_lowers[2], val_a_lowers[2])
.unwrap();
let sum = b
.f_add(types.float, None, b.f_add(types.float, None, x, y).unwrap(), z)
.f_add(
types.float,
None,
b.f_add(types.float, None, x, y).unwrap(),
z,
)
.unwrap();
let sqrt_low = b
.ext_inst(
@@ -767,7 +791,12 @@ pub(crate) fn compile_interval_function(
.f_mul(types.float, None, val_a_uppers[2], val_a_uppers[2])
.unwrap();
let sum = b
.f_add(types.float, None, b.f_add(types.float, None, x, y).unwrap(), z)
.f_add(
types.float,
None,
b.f_add(types.float, None, x, y).unwrap(),
z,
)
.unwrap();
let sqrt_high = b
.ext_inst(
@@ -857,24 +886,41 @@ pub(crate) fn compile_interval_function(
mapping.insert(instruction.outputs[0], length);
},
SSARecip => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
(
b.f_div(types.float, None, one, val_a.1).unwrap(),
b.f_div(types.float, None, one, val_a.0).unwrap(),
)
});
},
);
},
SSANegate => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.f_negate(types.float, None, val_a.1).unwrap(),
b.f_negate(types.float, None, val_a.0).unwrap(),
)
});
},
);
},
SSARound => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
@@ -893,12 +939,20 @@ pub(crate) fn compile_interval_function(
)
.unwrap(),
)
});
},
);
},
SSAAbs => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let zero_const = b.constant_bit32(types.float, (0.0f32).to_bits());
let llt = b.f_ord_less_than(types.bool, None, val_a.0, zero_const).unwrap();
let llt = b
.f_ord_less_than(types.bool, None, val_a.0, zero_const)
.unwrap();
let ugt = b
.f_ord_greater_than(types.bool, None, val_a.1, zero_const)
.unwrap();
@@ -938,10 +992,16 @@ pub(crate) fn compile_interval_function(
)
.unwrap();
(abs_low, abs_high)
});
},
);
},
SSAFloor => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
@@ -960,10 +1020,16 @@ pub(crate) fn compile_interval_function(
)
.unwrap(),
)
});
},
);
},
SSACeil => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
@@ -982,10 +1048,16 @@ pub(crate) fn compile_interval_function(
)
.unwrap(),
)
});
},
);
},
SSAFract => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
let ge1 = b
@@ -1028,11 +1100,18 @@ pub(crate) fn compile_interval_function(
)
.unwrap(),
)
});
},
);
},
SSASin | SSACos => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
let pi_2 = b.constant_bit32(types.float, (std::f32::consts::FRAC_PI_2).to_bits());
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let pi_2 =
b.constant_bit32(types.float, (std::f32::consts::FRAC_PI_2).to_bits());
let pi = b.constant_bit32(types.float, (std::f32::consts::PI).to_bits());
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
let two = b.constant_bit32(types.float, (2.0f32).to_bits());
@@ -1061,14 +1140,16 @@ pub(crate) fn compile_interval_function(
[IdRef(b.f_div(types.float, None, val_a.1, pi).unwrap())],
)
.unwrap();
let same_cycle =
b.f_ord_equal(types.bool, None, lower_cycle, upper_cycle).unwrap();
let same_cycle = b
.f_ord_equal(types.bool, None, lower_cycle, upper_cycle)
.unwrap();
let cycle = b.f_mod(types.float, None, upper_cycle, two).unwrap();
let within_one_cycle = b
.f_ord_equal(
types.bool,
None,
b.f_sub(types.float, None, upper_cycle, lower_cycle).unwrap(),
b.f_sub(types.float, None, upper_cycle, lower_cycle)
.unwrap(),
one,
)
.unwrap();
@@ -1151,63 +1232,347 @@ pub(crate) fn compile_interval_function(
)
.unwrap();
(lower, upper)
});
},
);
},
SSATan => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Tan as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let pi = b.constant_bit32(types.float, (std::f32::consts::PI).to_bits());
let nan = b.constant_bit32(types.float, (f32::NAN).to_bits());
let size = b.f_sub(types.float, None, val_a.1, val_a.0).unwrap();
let lower_tmp = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Tan as u32,
[IdRef(val_a.0)],
)
.unwrap();
let upper_tmp = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Tan as u32,
[IdRef(val_a.1)],
)
.unwrap();
let result_valid = b
.logical_and(
types.bool,
None,
b.f_ord_less_than(types.bool, None, size, pi).unwrap(),
b.f_ord_greater_than_equal(types.bool, None, upper_tmp, lower_tmp)
.unwrap(),
)
.unwrap();
(
b.select(types.float, None, result_valid, lower_tmp, nan)
.unwrap(),
b.select(types.float, None, result_valid, upper_tmp, nan)
.unwrap(),
)
},
);
},
SSAAsin => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Asin as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
let minus_one = b.constant_bit32(types.float, (-1.0f32).to_bits());
let nan = b.constant_bit32(types.float, (f32::NAN).to_bits());
let lower_tmp = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Asin as u32,
[IdRef(val_a.0)],
)
.unwrap();
let upper_tmp = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Asin as u32,
[IdRef(val_a.1)],
)
.unwrap();
let result_valid = b
.logical_and(
types.bool,
None,
b.f_ord_greater_than_equal(types.bool, None, val_a.0, minus_one)
.unwrap(),
b.f_ord_less_than_equal(types.bool, None, val_a.1, one)
.unwrap(),
)
.unwrap();
(
b.select(types.float, None, result_valid, lower_tmp, nan)
.unwrap(),
b.select(types.float, None, result_valid, upper_tmp, nan)
.unwrap(),
)
},
);
},
SSAAcos => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Acos as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
let minus_one = b.constant_bit32(types.float, (-1.0f32).to_bits());
let nan = b.constant_bit32(types.float, (f32::NAN).to_bits());
let lower_tmp = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Acos as u32,
[IdRef(val_a.0)],
)
.unwrap();
let upper_tmp = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Acos as u32,
[IdRef(val_a.1)],
)
.unwrap();
let result_valid = b
.logical_and(
types.bool,
None,
b.f_ord_greater_than_equal(types.bool, None, val_a.0, minus_one)
.unwrap(),
b.f_ord_less_than_equal(types.bool, None, val_a.1, one)
.unwrap(),
)
.unwrap();
(
b.select(types.float, None, result_valid, lower_tmp, nan)
.unwrap(),
b.select(types.float, None, result_valid, upper_tmp, nan)
.unwrap(),
)
},
);
},
SSAAtan => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Atan as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Atan as u32,
[IdRef(val_a.0)],
)
.unwrap(),
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Atan as u32,
[IdRef(val_a.1)],
)
.unwrap(),
)
},
);
},
SSAExp => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Exp as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Exp as u32,
[IdRef(val_a.0)],
)
.unwrap(),
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Exp as u32,
[IdRef(val_a.1)],
)
.unwrap(),
)
},
);
},
SSALog => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Log as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Log as u32,
[IdRef(val_a.0)],
)
.unwrap(),
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Log as u32,
[IdRef(val_a.1)],
)
.unwrap(),
)
},
);
},
SSASqrt => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.ext_inst(types.float, None, types.glsl, spirv::GLOp::Sqrt as u32, [IdRef(val_a)])
.unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
(
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Sqrt as u32,
[IdRef(val_a.0)],
)
.unwrap(),
b.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Sqrt as u32,
[IdRef(val_a.1)],
)
.unwrap(),
)
},
);
},
SSASquare => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
b.f_mul(types.float, None, val_a, val_a).unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
let ult = b.f_ord_less_than(types.bool, None, val_a.1, zero).unwrap();
let lgt = b
.f_ord_greater_than(types.bool, None, val_a.0, zero)
.unwrap();
let squ_lower = b.f_mul(types.float, None, val_a.0, val_a.0).unwrap();
let squ_upper = b.f_mul(types.float, None, val_a.1, val_a.1).unwrap();
let abs_lower = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::FAbs as u32,
[IdRef(val_a.0)],
)
.unwrap();
let abs_upper = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::FAbs as u32,
[IdRef(val_a.1)],
)
.unwrap();
let k = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::FMax as u32,
[IdRef(abs_lower), IdRef(abs_upper)],
)
.unwrap();
let squ_k = b.f_mul(types.float, None, k, k).unwrap();
(
b.select(
types.float,
None,
ult,
squ_upper,
b.select(types.float, None, lgt, squ_lower, zero).unwrap(),
)
.unwrap(),
b.select(
types.float,
None,
ult,
squ_lower,
b.select(types.float, None, lgt, squ_upper, squ_k).unwrap(),
)
.unwrap(),
)
},
);
},
SSACube => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
let square = b.f_mul(types.float, None, val_a, val_a).unwrap();
b.f_mul(types.float, None, val_a, square).unwrap()
});
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let squ_lower = b.f_mul(types.float, None, val_a.0, val_a.0).unwrap();
let squ_upper = b.f_mul(types.float, None, val_a.1, val_a.1).unwrap();
(
b.f_mul(types.float, None, val_a.0, squ_lower).unwrap(),
b.f_mul(types.float, None, val_a.1, squ_upper).unwrap(),
)
},
);
},
SSASmoothMin => {
param_three(types.float, &mut b, &mut mapping, instruction, |b, d1, d2, k| {
param_three(
types.float,
&mut b,
&mut mapping,
instruction,
|b, d1, d2, k| {
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
let zero_const = b.constant_bit32(types.float, (0.0f32).to_bits());
let one_const = b.constant_bit32(types.float, (1.0f32).to_bits());
@@ -1237,10 +1602,16 @@ pub(crate) fn compile_interval_function(
)
.unwrap();
b.f_sub(types.float, None, mix, kh_negh).unwrap()
});
},
);
},
SSASmoothMax => {
param_three(types.float, &mut b, &mut mapping, instruction, |b, d1, d2, k| {
param_three(
types.float,
&mut b,
&mut mapping,
instruction,
|b, d1, d2, k| {
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
let zero_const = b.constant_bit32(types.float, (0.0f32).to_bits());
let one_const = b.constant_bit32(types.float, (1.0f32).to_bits());
@@ -1271,7 +1642,8 @@ pub(crate) fn compile_interval_function(
)
.unwrap();
b.f_add(types.float, None, mix, kh_negh).unwrap()
});
},
);
},
SSASmoothMinMaterial => todo!(),
SSASmoothMaxMaterial => todo!(),
@@ -1342,11 +1714,21 @@ pub(crate) fn compile_interval_function(
.collect::<Vec<_>>();
let pos = b.composite_construct(types.vec3, None, pos_part).unwrap();
let radius =
input_resolve(types.float, &mut b, &mapping, instruction.inputs[3 as usize]);
let radius = input_resolve(
types.float,
&mut b,
&mapping,
instruction.inputs[3 as usize],
);
let length = b
.ext_inst(types.float, None, types.glsl, spirv::GLOp::Length as u32, [IdRef(pos)])
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Length as u32,
[IdRef(pos)],
)
.unwrap();
let sphere = b.f_sub(types.float, None, length, radius).unwrap();
@@ -1380,7 +1762,13 @@ pub(crate) fn compile_interval_function(
let dim = b.composite_construct(types.vec3, None, dim_part).unwrap();
let abs = b
.ext_inst(types.vec3, None, types.glsl, spirv::GLOp::FAbs as u32, [IdRef(pos)])
.ext_inst(
types.vec3,
None,
types.glsl,
spirv::GLOp::FAbs as u32,
[IdRef(pos)],
)
.unwrap();
let q = b.f_sub(types.vec3, None, abs, dim).unwrap();
@@ -1461,14 +1849,28 @@ pub(crate) fn compile_interval_function(
.composite_construct(types.vec2, None, [pos_part[0], pos_part[2]])
.unwrap();
let rad1 =
input_resolve(types.float, &mut b, &mapping, instruction.inputs[3 as usize]);
let rad2 =
input_resolve(types.float, &mut b, &mapping, instruction.inputs[4 as usize]);
let rad1 = input_resolve(
types.float,
&mut b,
&mapping,
instruction.inputs[3 as usize],
);
let rad2 = input_resolve(
types.float,
&mut b,
&mapping,
instruction.inputs[4 as usize],
);
let dot = b.dot(types.float, None, pos_vec2, pos_vec2).unwrap();
let sqrt = b
.ext_inst(types.float, None, types.glsl, spirv::GLOp::Sqrt as u32, [IdRef(dot)])
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Sqrt as u32,
[IdRef(dot)],
)
.unwrap();
let subtx = b.f_sub(types.float, None, sqrt, rad1).unwrap();
@@ -1477,7 +1879,13 @@ pub(crate) fn compile_interval_function(
.unwrap();
let length = b
.ext_inst(types.float, None, types.glsl, spirv::GLOp::Length as u32, [IdRef(q)])
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Length as u32,
[IdRef(q)],
)
.unwrap();
mapping.insert(
@@ -1498,12 +1906,15 @@ pub(crate) fn compile_interval_function(
let onen = b.constant_bit32(types.float, (-1.0f32).to_bits());
let equal = b.f_ord_equal(types.bool, None, val_a, val_b).unwrap();
let less = b.f_ord_less_than(types.bool, None, val_a, val_b).unwrap();
let more = b.f_ord_greater_than(types.bool, None, val_a, val_b).unwrap();
let more = b
.f_ord_greater_than(types.bool, None, val_a, val_b)
.unwrap();
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();
let select_eq = b
.select(types.float, None, equal, zero, select_more)
.unwrap();
select_eq
},
);
@@ -1535,12 +1946,18 @@ pub(crate) fn compile_interval_function(
);
},
SSANot => {
param_one(types.float, &mut b, &mut mapping, instruction, |b, val_a| {
param_one(
types.float,
&mut b,
&mut mapping,
instruction,
|b, val_a| {
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
let equal = b.f_ord_equal(types.bool, None, val_a, zero).unwrap();
b.select(types.float, None, equal, one, zero).unwrap()
});
},
);
},
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
pub(crate) mod gradient;
pub(crate) mod point;
//pub(crate) mod gradient;
//pub(crate) mod interval;
pub(crate) mod point;
#[derive(Debug, Clone, Copy)]
pub(crate) struct SpirVTypes {
+4 -4
View File
@@ -228,11 +228,11 @@ impl Interval {
pub fn acos(self) -> Self {
let lower = (self.lower.simd_lt(VALUE_M1) | self.upper.simd_gt(VALUE_1)).select(
VALUE_NAN,
Value::from_array(self.upper.to_array().map(|f| f.asin())),
Value::from_array(self.upper.to_array().map(|f| f.acos())),
);
let upper = (self.lower.simd_lt(VALUE_M1) | self.upper.simd_gt(VALUE_1)).select(
VALUE_NAN,
Value::from_array(self.lower.to_array().map(|f| f.asin())),
Value::from_array(self.lower.to_array().map(|f| f.acos())),
);
Interval::new(lower, upper)
}
@@ -240,8 +240,8 @@ impl Interval {
/// Computes the arctangent of the interval
#[inline]
pub fn atan(self) -> Self {
let lower = Value::from_array(self.lower.to_array().map(|f| f.asin()));
let upper = Value::from_array(self.upper.to_array().map(|f| f.asin()));
let lower = Value::from_array(self.lower.to_array().map(|f| f.atan()));
let upper = Value::from_array(self.upper.to_array().map(|f| f.atan()));
Interval::new(lower, upper)
}