Drop OPNormalize
This commit is contained in:
@@ -158,16 +158,12 @@ pub(crate) enum InstructionSet {
|
|||||||
OPLength = (37),
|
OPLength = (37),
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
/// Returns the normalised version of a vector.
|
|
||||||
OPNormalize = (38),
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
#[allow(dead_code)]
|
|
||||||
/// Returns the dot product of two vectors.
|
/// Returns the dot product of two vectors.
|
||||||
OPDot = (39),
|
OPDot = (38),
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
/// Returns the length (magnitude) of the vector between two vectors.
|
/// Returns the length (magnitude) of the vector between two vectors.
|
||||||
OPDistance = (40),
|
OPDistance = (39),
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
/// No operation.
|
/// No operation.
|
||||||
|
|||||||
@@ -248,39 +248,6 @@ impl<'csg> PointInterpreter<'csg> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
SSANormalize => {
|
|
||||||
let val_a = (0..instruction.opcode.size)
|
|
||||||
.map(|i| self.load(instruction.inputs[i as usize]))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
match instruction.opcode.size {
|
|
||||||
1 => {
|
|
||||||
self.store(instruction.outputs[0], VALUE_1);
|
|
||||||
},
|
|
||||||
2 => {
|
|
||||||
let max = val_a[0].simd_max(val_a[1]);
|
|
||||||
self.store(instruction.outputs[0], val_a[0] / max);
|
|
||||||
self.store(instruction.outputs[1], val_a[1] / max);
|
|
||||||
},
|
|
||||||
3 => {
|
|
||||||
let max = val_a[0].simd_max(val_a[1]).simd_max(val_a[2]);
|
|
||||||
self.store(instruction.outputs[0], val_a[0] / max);
|
|
||||||
self.store(instruction.outputs[1], val_a[1] / max);
|
|
||||||
self.store(instruction.outputs[2], val_a[2] / max);
|
|
||||||
},
|
|
||||||
4 => {
|
|
||||||
let max = val_a[0]
|
|
||||||
.simd_max(val_a[1])
|
|
||||||
.simd_max(val_a[2])
|
|
||||||
.simd_max(val_a[3]);
|
|
||||||
self.store(instruction.outputs[0], val_a[0] / max);
|
|
||||||
self.store(instruction.outputs[1], val_a[1] / max);
|
|
||||||
self.store(instruction.outputs[2], val_a[2] / max);
|
|
||||||
self.store(instruction.outputs[3], val_a[3] / max);
|
|
||||||
},
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
SSANegate => {
|
SSANegate => {
|
||||||
self.param_one(instruction, |val_a| -val_a);
|
self.param_one(instruction, |val_a| -val_a);
|
||||||
},
|
},
|
||||||
@@ -721,42 +688,6 @@ impl<'csg> IntervalInterpreter<'csg> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
SSANormalize => {
|
|
||||||
let val_a = (0..instruction.opcode.size)
|
|
||||||
.map(|i| self.load(instruction.inputs[i as usize]))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
match instruction.opcode.size {
|
|
||||||
1 => {
|
|
||||||
self.store(instruction.outputs[0], Interval::ONE);
|
|
||||||
},
|
|
||||||
2 => {
|
|
||||||
let max = val_a[0].max_choice(val_a[1]).0;
|
|
||||||
self.store(instruction.outputs[0], val_a[0] / max);
|
|
||||||
self.store(instruction.outputs[1], val_a[1] / max);
|
|
||||||
},
|
|
||||||
3 => {
|
|
||||||
let max = val_a[0].max_choice(val_a[1]).0.max_choice(val_a[2]).0;
|
|
||||||
self.store(instruction.outputs[0], val_a[0] / max);
|
|
||||||
self.store(instruction.outputs[1], val_a[1] / max);
|
|
||||||
self.store(instruction.outputs[2], val_a[2] / max);
|
|
||||||
},
|
|
||||||
4 => {
|
|
||||||
let max = val_a[0]
|
|
||||||
.max_choice(val_a[1])
|
|
||||||
.0
|
|
||||||
.max_choice(val_a[2])
|
|
||||||
.0
|
|
||||||
.max_choice(val_a[3])
|
|
||||||
.0;
|
|
||||||
self.store(instruction.outputs[0], val_a[0] / max);
|
|
||||||
self.store(instruction.outputs[1], val_a[1] / max);
|
|
||||||
self.store(instruction.outputs[2], val_a[2] / max);
|
|
||||||
self.store(instruction.outputs[3], val_a[3] / max);
|
|
||||||
},
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
SSANegate => {
|
SSANegate => {
|
||||||
self.param_one(instruction, |val_a| -val_a);
|
self.param_one(instruction, |val_a| -val_a);
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-40
@@ -49,7 +49,6 @@ pub(crate) enum SSAOpcode {
|
|||||||
SSADot,
|
SSADot,
|
||||||
SSALength,
|
SSALength,
|
||||||
SSADistance,
|
SSADistance,
|
||||||
SSANormalize,
|
|
||||||
|
|
||||||
#[default]
|
#[default]
|
||||||
SSAStop,
|
SSAStop,
|
||||||
@@ -148,7 +147,7 @@ impl SSAOpcodeSized {
|
|||||||
match self.opcode {
|
match self.opcode {
|
||||||
SSAStop | SSAReturn | SSAPosition | SSAMinMaterial | SSAMaxMaterial
|
SSAStop | SSAReturn | SSAPosition | SSAMinMaterial | SSAMaxMaterial
|
||||||
| SSASmoothMinMaterial | SSASmoothMaxMaterial | SSACross | SSASDFSphere | SSASDFBox
|
| SSASmoothMinMaterial | SSASmoothMaxMaterial | SSACross | SSASDFSphere | SSASDFBox
|
||||||
| SSASDFTorus | SSADot | SSADistance | SSALength | SSANormalize => (0, 0),
|
| SSASDFTorus | SSADot | SSADistance | SSALength => (0, 0),
|
||||||
SSAAdd | SSASub | SSAMul | SSADiv | SSAAtan2 | SSAMin | SSACompare | SSAMod
|
SSAAdd | SSASub | SSAMul | SSADiv | SSAAtan2 | SSAMin | SSACompare | SSAMod
|
||||||
| SSAAnd | SSAOr => (2, 1),
|
| SSAAnd | SSAOr => (2, 1),
|
||||||
SSASmoothMin | SSASmoothMax | SSAClamp | SSAMix | SSAFMA => (3, 1),
|
SSASmoothMin | SSASmoothMax | SSAClamp | SSAMix | SSAFMA => (3, 1),
|
||||||
@@ -187,7 +186,6 @@ impl SSAOpcodeSized {
|
|||||||
SSADot => opcode_drop(OPDot, self.size),
|
SSADot => opcode_drop(OPDot, self.size),
|
||||||
SSALength => opcode_drop(OPLength, self.size),
|
SSALength => opcode_drop(OPLength, self.size),
|
||||||
SSADistance => opcode_drop(OPDistance, self.size),
|
SSADistance => opcode_drop(OPDistance, self.size),
|
||||||
SSANormalize => opcode_drop(OPNormalize, self.size),
|
|
||||||
SSANegate => opcode_drop(OPNegate, self.size),
|
SSANegate => opcode_drop(OPNegate, self.size),
|
||||||
SSARound => opcode_drop(OPRound, self.size),
|
SSARound => opcode_drop(OPRound, self.size),
|
||||||
SSAAbs => opcode_drop(OPAbs, self.size),
|
SSAAbs => opcode_drop(OPAbs, self.size),
|
||||||
@@ -842,43 +840,6 @@ impl SSATape {
|
|||||||
};
|
};
|
||||||
mapping.insert(instruction.outputs[0], distance);
|
mapping.insert(instruction.outputs[0], distance);
|
||||||
},
|
},
|
||||||
SSANormalize => {
|
|
||||||
let val_a = (0..instruction.opcode.size)
|
|
||||||
.map(|i| {
|
|
||||||
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let val_b = (instruction.opcode.size..(instruction.opcode.size * 2))
|
|
||||||
.map(|i| {
|
|
||||||
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if instruction.opcode.size == 1 {
|
|
||||||
let normal = b.constant_bit32(float, (1.0f32).to_bits());
|
|
||||||
mapping.insert(instruction.outputs[0], normal);
|
|
||||||
} else {
|
|
||||||
let vector =
|
|
||||||
[void, float, vec2, vec3, vec4][instruction.opcode.size as usize];
|
|
||||||
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
|
||||||
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
|
||||||
let normal = b
|
|
||||||
.ext_inst(
|
|
||||||
vector,
|
|
||||||
None,
|
|
||||||
glsl,
|
|
||||||
spirv::GLOp::Normalize as u32,
|
|
||||||
[IdRef(val_a), IdRef(val_b)],
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
for i in 0..instruction.opcode.size as usize {
|
|
||||||
mapping.insert(
|
|
||||||
instruction.outputs[i],
|
|
||||||
b.composite_extract(float, None, normal, [i as u32])
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
SSARecip => {
|
SSARecip => {
|
||||||
param_one(float, &mut b, &mut mapping, instruction, |b, val_a| {
|
param_one(float, &mut b, &mut mapping, instruction, |b, val_a| {
|
||||||
let one = b.constant_bit32(float, (1.0f32).to_bits());
|
let one = b.constant_bit32(float, (1.0f32).to_bits());
|
||||||
|
|||||||
Reference in New Issue
Block a user