allow non-pointers
This commit is contained in:
Generated
+1
-1
@@ -3113,7 +3113,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tape-load"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"bevy_reflect",
|
||||
"foldhash 0.1.5",
|
||||
|
||||
@@ -16,7 +16,7 @@ where
|
||||
//warn!("WAITING FOR HOST BUFFER FREE");
|
||||
thread::yield_now();
|
||||
writer = device_local.write();
|
||||
},
|
||||
}
|
||||
_ => break 'writerloop,
|
||||
}
|
||||
}
|
||||
|
||||
+31
-31
@@ -769,7 +769,7 @@ impl App {
|
||||
info!("event: {:?}", event);
|
||||
watcher_glsl_changed.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
},
|
||||
}
|
||||
Err(e) => error!("watch error: {:?}", e),
|
||||
},
|
||||
)
|
||||
@@ -1122,13 +1122,13 @@ impl ApplicationHandler for App {
|
||||
match &event {
|
||||
WindowEvent::CloseRequested => {
|
||||
event_loop.exit();
|
||||
},
|
||||
}
|
||||
WindowEvent::Resized(_) => {
|
||||
rcx.recreate_swapchain = true;
|
||||
},
|
||||
}
|
||||
WindowEvent::ScaleFactorChanged { .. } => {
|
||||
rcx.recreate_swapchain = true;
|
||||
},
|
||||
}
|
||||
WindowEvent::DroppedFile(path) => {
|
||||
if let Ok(file) = std::fs::File::open(path) {
|
||||
if let Ok(mut mesh) = load_obj(
|
||||
@@ -1147,7 +1147,7 @@ impl ApplicationHandler for App {
|
||||
} else {
|
||||
error!("Could not open path {}", path.display());
|
||||
}
|
||||
},
|
||||
}
|
||||
WindowEvent::MouseInput {
|
||||
device_id: d,
|
||||
state: s,
|
||||
@@ -1158,7 +1158,7 @@ impl ApplicationHandler for App {
|
||||
if b == &MouseButton::Right {
|
||||
self.cstate.looking = s == &ElementState::Pressed;
|
||||
}
|
||||
},
|
||||
}
|
||||
WindowEvent::KeyboardInput {
|
||||
device_id: _,
|
||||
event: input,
|
||||
@@ -1166,19 +1166,19 @@ impl ApplicationHandler for App {
|
||||
} => match input.physical_key {
|
||||
PhysicalKey::Code(KeyCode::KeyW) => {
|
||||
self.cstate.keys.w = input.state == ElementState::Pressed;
|
||||
},
|
||||
}
|
||||
PhysicalKey::Code(KeyCode::KeyS) => {
|
||||
self.cstate.keys.s = input.state == ElementState::Pressed;
|
||||
},
|
||||
}
|
||||
PhysicalKey::Code(KeyCode::KeyA) => {
|
||||
self.cstate.keys.a = input.state == ElementState::Pressed;
|
||||
},
|
||||
}
|
||||
PhysicalKey::Code(KeyCode::KeyD) => {
|
||||
self.cstate.keys.d = input.state == ElementState::Pressed;
|
||||
},
|
||||
}
|
||||
PhysicalKey::Code(KeyCode::ShiftLeft) => {
|
||||
self.cstate.looking = input.state == ElementState::Pressed;
|
||||
},
|
||||
}
|
||||
PhysicalKey::Code(KeyCode::Space) => {
|
||||
if input.state == ElementState::Pressed {
|
||||
self.thread_work_creation
|
||||
@@ -1198,18 +1198,18 @@ impl ApplicationHandler for App {
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
},
|
||||
}
|
||||
PhysicalKey::Code(KeyCode::KeyG) => {
|
||||
if input.state == ElementState::Pressed {
|
||||
self.draw_gui = !self.draw_gui;
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
WindowEvent::RedrawRequested => {
|
||||
self.redraw(rcx);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1568,10 +1568,10 @@ impl App {
|
||||
self.gstate.csg[index as usize] = csg;
|
||||
}
|
||||
self.recreate_pipelines = true;
|
||||
},
|
||||
WorkComplete::GetPushConstants(..) => {},
|
||||
WorkComplete::RecompilePipelines(..) => {},
|
||||
WorkComplete::RecompileShaders(..) => {},
|
||||
}
|
||||
WorkComplete::GetPushConstants(..) => {}
|
||||
WorkComplete::RecompilePipelines(..) => {}
|
||||
WorkComplete::RecompileShaders(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1714,10 +1714,10 @@ impl App {
|
||||
index,
|
||||
))
|
||||
.unwrap();
|
||||
},
|
||||
}
|
||||
WorkComplete::RecompilePipelines(_index) => {
|
||||
csg_pipelines_left -= 1;
|
||||
},
|
||||
}
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
@@ -1736,7 +1736,7 @@ impl App {
|
||||
match work {
|
||||
WorkComplete::RecompilePipelines(_index) => {
|
||||
csg_pipelines_left -= 1;
|
||||
},
|
||||
}
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
@@ -1816,7 +1816,7 @@ impl App {
|
||||
} else {
|
||||
work_for_later.push(work);
|
||||
}
|
||||
},
|
||||
}
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
@@ -2042,7 +2042,7 @@ impl App {
|
||||
Err(VulkanError::OutOfDate) => {
|
||||
rcx.recreate_swapchain = true;
|
||||
return;
|
||||
},
|
||||
}
|
||||
Err(e) => panic!("Failed to acquire next image: {e}"),
|
||||
};
|
||||
|
||||
@@ -2097,7 +2097,7 @@ impl App {
|
||||
write.lowest_corner = lowest_corner;
|
||||
write.blas = None;
|
||||
push_constants_left -= 1;
|
||||
},
|
||||
}
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
@@ -2197,20 +2197,20 @@ impl App {
|
||||
match future.map_err(Validated::unwrap) {
|
||||
Ok(future) => {
|
||||
rcx.previous_frame_end[image_index] = Some(future);
|
||||
},
|
||||
}
|
||||
Err(VulkanError::OutOfDate) => {
|
||||
rcx.recreate_swapchain = true;
|
||||
rcx.previous_frame_end[image_index] = None;
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to flush future: {e:?}");
|
||||
rcx.previous_frame_end[image_index] = None;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
for work in self.thread_work_completion.try_iter() {
|
||||
match work {
|
||||
WorkComplete::GetPushConstants(..) => {},
|
||||
WorkComplete::GetPushConstants(..) => {}
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
@@ -2231,7 +2231,7 @@ impl App {
|
||||
warn!("WAITING FOR HOST BUFFER FREE");
|
||||
thread::yield_now();
|
||||
reader = csg.aabb_buffer[image_index].read();
|
||||
},
|
||||
}
|
||||
_ => break 'writerloop,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
"CSG compile took {} milliseconds",
|
||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||
);
|
||||
},
|
||||
}
|
||||
WorkItem::GetPushConstants(csg, time, index) => {
|
||||
let csg = csg.read().unwrap();
|
||||
|
||||
@@ -218,7 +218,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
|
||||
send.send(WorkComplete::GetPushConstants(dim, lowest, index))
|
||||
.unwrap();
|
||||
},
|
||||
}
|
||||
WorkItem::RecompileShaders(csg, device, replacement_modules, index) => {
|
||||
let csg_start = Instant::now();
|
||||
let csg = csg.read().unwrap();
|
||||
@@ -240,7 +240,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
index,
|
||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||
);
|
||||
},
|
||||
}
|
||||
WorkItem::RecompilePipelines(csg, device, cache, debug, index) => {
|
||||
let csg_start = Instant::now();
|
||||
let mut csg = csg.write().unwrap();
|
||||
@@ -263,7 +263,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
index,
|
||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||
);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ fn sdf_specialize_module(
|
||||
module: Module,
|
||||
name: &str,
|
||||
) -> Arc<ShaderModule> {
|
||||
let new_module = parts.compile_to_spirv(Some(module));
|
||||
let new_module = parts.compile_to_spirv(Some(module), true);
|
||||
|
||||
let assembled_module = new_module.assemble();
|
||||
let module_as_bytes = assembled_module
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tape-load"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -80,36 +80,36 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
match instruction.opcode.opcode {
|
||||
SSAReturn => {
|
||||
return self.load(instruction.inputs[0]);
|
||||
},
|
||||
}
|
||||
SSAPosition => {
|
||||
self.store(instruction.outputs[0], px);
|
||||
self.store(instruction.outputs[1], py);
|
||||
self.store(instruction.outputs[2], pz);
|
||||
self.store(instruction.outputs[3], time);
|
||||
},
|
||||
}
|
||||
SSAAdd => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a + val_b);
|
||||
},
|
||||
}
|
||||
SSASub => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a - val_b);
|
||||
},
|
||||
}
|
||||
SSAMul => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a * val_b);
|
||||
},
|
||||
}
|
||||
SSADiv => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a / val_b);
|
||||
},
|
||||
}
|
||||
SSAMod => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a % val_b);
|
||||
},
|
||||
}
|
||||
SSAAtan2 => self.param_two(instruction, |val_a, val_b| val_a.atan2(val_b)),
|
||||
SSAMin => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.min_choice(val_b).0);
|
||||
},
|
||||
}
|
||||
SSAMinMaterial => todo!(),
|
||||
SSAMax => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.max_choice(val_b).0);
|
||||
},
|
||||
}
|
||||
SSAMaxMaterial => todo!(),
|
||||
SSADot => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
@@ -127,17 +127,17 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
(val_a[0] * val_b[0])
|
||||
+ (val_a[1] * val_b[1])
|
||||
+ (val_a[2] * val_b[2])
|
||||
},
|
||||
}
|
||||
4 => {
|
||||
(val_a[0] * val_b[0])
|
||||
+ (val_a[1] * val_b[1])
|
||||
+ (val_a[2] * val_b[2])
|
||||
+ (val_a[3] * val_b[3])
|
||||
},
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSALength => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| self.load(instruction.inputs[i as usize]))
|
||||
@@ -190,7 +190,7 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSADistance => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| self.load(instruction.inputs[i as usize]))
|
||||
@@ -251,85 +251,85 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSANegate => {
|
||||
self.param_one(instruction, |val_a| -val_a);
|
||||
},
|
||||
}
|
||||
SSARound => {
|
||||
self.param_one(instruction, |val_a| val_a.round());
|
||||
},
|
||||
}
|
||||
SSAAbs => {
|
||||
self.param_one(instruction, |val_a| val_a.abs());
|
||||
},
|
||||
}
|
||||
SSAFloor => {
|
||||
self.param_one(instruction, |val_a| val_a.floor());
|
||||
},
|
||||
}
|
||||
SSACeil => {
|
||||
self.param_one(instruction, |val_a| val_a.ceil());
|
||||
},
|
||||
}
|
||||
SSAFract => {
|
||||
self.param_one(instruction, |val_a| val_a.fract());
|
||||
},
|
||||
}
|
||||
SSASin => {
|
||||
self.param_one(instruction, |val_a| val_a.sin());
|
||||
},
|
||||
}
|
||||
SSACos => {
|
||||
self.param_one(instruction, |val_a| val_a.cos());
|
||||
},
|
||||
}
|
||||
SSATan => {
|
||||
self.param_one(instruction, |val_a| val_a.tan());
|
||||
},
|
||||
}
|
||||
SSAAsin => {
|
||||
self.param_one(instruction, |val_a| val_a.asin());
|
||||
},
|
||||
}
|
||||
SSAAcos => {
|
||||
self.param_one(instruction, |val_a| val_a.acos());
|
||||
},
|
||||
}
|
||||
SSAAtan => {
|
||||
self.param_one(instruction, |val_a| val_a.atan());
|
||||
},
|
||||
}
|
||||
SSAExp => {
|
||||
self.param_one(instruction, |val_a| val_a.exp());
|
||||
},
|
||||
}
|
||||
SSALog => {
|
||||
self.param_one(instruction, |val_a| val_a.ln());
|
||||
},
|
||||
}
|
||||
SSASqrt => {
|
||||
self.param_one(instruction, |val_a| val_a.sqrt());
|
||||
},
|
||||
}
|
||||
SSASquare => {
|
||||
self.param_one(instruction, |val_a| val_a.square());
|
||||
},
|
||||
}
|
||||
SSACube => {
|
||||
self.param_one(instruction, |val_a| val_a.cube());
|
||||
},
|
||||
}
|
||||
SSASmoothMin => {
|
||||
self.param_three(instruction, |d1, d2, k| {
|
||||
let h = (Interval::HALF + (Interval::HALF * (d2 - d1) / k))
|
||||
.clamp(Interval::ZERO, Interval::ONE);
|
||||
((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);
|
||||
((d2 * (Interval::ONE - h)) + (-d1 * h)) + k * h * (Interval::ONE - h)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMinMaterial => todo!(),
|
||||
SSASmoothMaxMaterial => todo!(),
|
||||
SSAClamp => {
|
||||
self.param_three(instruction, |val_a, val_b, val_c| val_a.clamp(val_b, val_c));
|
||||
},
|
||||
}
|
||||
SSAMix => {
|
||||
self.param_three(instruction, |val_a, val_b, val_c| {
|
||||
(val_a * (Interval::ONE - val_c)) + (val_b * val_c)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFMA => {
|
||||
self.param_three(instruction, |val_a, val_b, val_c| (val_a * val_b) + val_c);
|
||||
},
|
||||
}
|
||||
SSASDFSphere => {
|
||||
let pos_x = self.load(instruction.inputs[0]);
|
||||
let pos_y = self.load(instruction.inputs[1]);
|
||||
@@ -339,7 +339,7 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
instruction.outputs[0],
|
||||
((pos_x.square()) + (pos_y.square()) + (pos_z.square())).sqrt() - radius,
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFBox => {
|
||||
let pos_x = self.load(instruction.inputs[0]);
|
||||
let pos_y = self.load(instruction.inputs[1]);
|
||||
@@ -361,7 +361,7 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
.min_choice(Interval::ZERO)
|
||||
.0,
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFTorus => {
|
||||
let pos_x = self.load(instruction.inputs[0]);
|
||||
let pos_y = self.load(instruction.inputs[1]);
|
||||
@@ -373,22 +373,22 @@ impl<'csg> IntervalInterpreter<'csg> {
|
||||
instruction.outputs[0],
|
||||
((q.square()) + (pos_y.square())).sqrt() - radius2,
|
||||
);
|
||||
},
|
||||
}
|
||||
SSACompare => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.compare(val_b));
|
||||
},
|
||||
}
|
||||
SSAAnd => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.and_choice(val_b).0);
|
||||
},
|
||||
}
|
||||
SSAOr => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.or_choice(val_b).0);
|
||||
},
|
||||
}
|
||||
SSARecip => {
|
||||
self.param_one(instruction, |val_a| val_a.recip());
|
||||
},
|
||||
}
|
||||
SSANot => {
|
||||
self.param_one(instruction, |val_a| !val_a);
|
||||
},
|
||||
}
|
||||
SSAStop => return Interval::ZERO,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,28 +79,28 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
match instruction.opcode.opcode {
|
||||
SSAReturn => {
|
||||
return self.load(instruction.inputs[0]);
|
||||
},
|
||||
}
|
||||
SSAPosition => {
|
||||
self.store(instruction.outputs[0], px);
|
||||
self.store(instruction.outputs[1], py);
|
||||
self.store(instruction.outputs[2], pz);
|
||||
self.store(instruction.outputs[3], time);
|
||||
},
|
||||
}
|
||||
SSAAdd => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a + val_b);
|
||||
},
|
||||
}
|
||||
SSASub => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a - val_b);
|
||||
},
|
||||
}
|
||||
SSAMul => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a * val_b);
|
||||
},
|
||||
}
|
||||
SSADiv => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a / val_b);
|
||||
},
|
||||
}
|
||||
SSAMod => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a % val_b);
|
||||
},
|
||||
}
|
||||
SSAAtan2 => self.param_two(instruction, |val_a, val_b| {
|
||||
let mut val_a = val_a.to_array();
|
||||
let val_b = val_b.to_array();
|
||||
@@ -111,11 +111,11 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
}),
|
||||
SSAMin => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.simd_min(val_b));
|
||||
},
|
||||
}
|
||||
SSAMinMaterial => todo!(),
|
||||
SSAMax => {
|
||||
self.param_two(instruction, |val_a, val_b| val_a.simd_max(val_b));
|
||||
},
|
||||
}
|
||||
SSAMaxMaterial => todo!(),
|
||||
SSADot => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
@@ -133,17 +133,17 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
(val_a[0] * val_b[0])
|
||||
+ (val_a[1] * val_b[1])
|
||||
+ (val_a[2] * val_b[2])
|
||||
},
|
||||
}
|
||||
4 => {
|
||||
(val_a[0] * val_b[0])
|
||||
+ (val_a[1] * val_b[1])
|
||||
+ (val_a[2] * val_b[2])
|
||||
+ (val_a[3] * val_b[3])
|
||||
},
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSALength => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| self.load(instruction.inputs[i as usize]))
|
||||
@@ -165,7 +165,7 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSADistance => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| self.load(instruction.inputs[i as usize]))
|
||||
@@ -194,97 +194,97 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSANegate => {
|
||||
self.param_one(instruction, |val_a| -val_a);
|
||||
},
|
||||
}
|
||||
SSARound => {
|
||||
self.param_one(instruction, |val_a| val_a.round());
|
||||
},
|
||||
}
|
||||
SSAAbs => {
|
||||
self.param_one(instruction, |val_a| val_a.abs());
|
||||
},
|
||||
}
|
||||
SSAFloor => {
|
||||
self.param_one(instruction, |val_a| val_a.floor());
|
||||
},
|
||||
}
|
||||
SSACeil => {
|
||||
self.param_one(instruction, |val_a| val_a.ceil());
|
||||
},
|
||||
}
|
||||
SSAFract => {
|
||||
self.param_one(instruction, glfract);
|
||||
},
|
||||
}
|
||||
SSASin => {
|
||||
self.param_one(instruction, |val_a| val_a.sin());
|
||||
},
|
||||
}
|
||||
SSACos => {
|
||||
self.param_one(instruction, |val_a| val_a.cos());
|
||||
},
|
||||
}
|
||||
SSATan => {
|
||||
self.param_one(instruction, |val_a| {
|
||||
Value::from_array(val_a.to_array().map(|f| f.tan()))
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAsin => {
|
||||
self.param_one(instruction, |val_a| {
|
||||
Value::from_array(val_a.to_array().map(|f| f.asin()))
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAcos => {
|
||||
self.param_one(instruction, |val_a| {
|
||||
Value::from_array(val_a.to_array().map(|f| f.acos()))
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAtan => {
|
||||
self.param_one(instruction, |val_a| {
|
||||
Value::from_array(val_a.to_array().map(|f| f.atan()))
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAExp => {
|
||||
self.param_one(instruction, |val_a| val_a.exp());
|
||||
},
|
||||
}
|
||||
SSALog => {
|
||||
self.param_one(instruction, |val_a| val_a.ln());
|
||||
},
|
||||
}
|
||||
SSASqrt => {
|
||||
self.param_one(instruction, |val_a| val_a.sqrt());
|
||||
},
|
||||
}
|
||||
SSASquare => {
|
||||
self.param_one(instruction, |val_a| val_a * val_a);
|
||||
},
|
||||
}
|
||||
SSACube => {
|
||||
self.param_one(instruction, |val_a| val_a * val_a * val_a);
|
||||
},
|
||||
}
|
||||
SSASmoothMin => {
|
||||
self.param_three(instruction, |d1, d2, k| {
|
||||
let h =
|
||||
(VALUE_05 + (VALUE_05 * (d2 - d1) / k)).simd_clamp(VALUE_0, VALUE_1);
|
||||
((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);
|
||||
((d2 * (VALUE_1 - h)) + (-d1 * h)) + k * h * (VALUE_1 - h)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMinMaterial => todo!(),
|
||||
SSASmoothMaxMaterial => todo!(),
|
||||
SSAClamp => {
|
||||
self.param_three(instruction, |val_a, val_b, val_c| {
|
||||
val_a.simd_clamp(val_b, val_c)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAMix => {
|
||||
self.param_three(instruction, |val_a, val_b, val_c| {
|
||||
(val_a * (VALUE_1 - val_c)) + (val_b * val_c)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFMA => {
|
||||
self.param_three(instruction, |val_a, val_b, val_c| {
|
||||
val_a.mul_add(val_b, val_c)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASDFSphere => {
|
||||
let pos_x = self.load(instruction.inputs[0]);
|
||||
let pos_y = self.load(instruction.inputs[1]);
|
||||
@@ -294,7 +294,7 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
instruction.outputs[0],
|
||||
((pos_x * pos_x) + (pos_y * pos_y) + (pos_z * pos_z)).sqrt() - radius,
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFBox => {
|
||||
let pos_x = self.load(instruction.inputs[0]);
|
||||
let pos_y = self.load(instruction.inputs[1]);
|
||||
@@ -313,7 +313,7 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
((qxmax * qxmax) + (qymax * qymax) + (qzmax * qzmax)).sqrt()
|
||||
+ qx.simd_max(qy.simd_max(qz)).simd_min(VALUE_0),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFTorus => {
|
||||
let pos_x = self.load(instruction.inputs[0]);
|
||||
let pos_y = self.load(instruction.inputs[1]);
|
||||
@@ -325,32 +325,32 @@ impl<'csg> PointInterpreter<'csg> {
|
||||
instruction.outputs[0],
|
||||
((q * q) + (pos_y * pos_y)).sqrt() - radius2,
|
||||
);
|
||||
},
|
||||
}
|
||||
SSACompare => {
|
||||
self.param_two(instruction, |val_a, val_b| {
|
||||
val_a
|
||||
.simd_gt(val_b)
|
||||
.select(VALUE_1, val_a.simd_lt(val_b).select(VALUE_M1, VALUE_0))
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAnd => {
|
||||
self.param_two(instruction, |val_a, val_b| {
|
||||
val_a.simd_eq(VALUE_0).select(val_a, val_b)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAOr => {
|
||||
self.param_two(instruction, |val_a, val_b| {
|
||||
val_a.simd_eq(VALUE_0).select(val_b, val_a)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSARecip => {
|
||||
self.param_one(instruction, |val_a| val_a.recip());
|
||||
},
|
||||
}
|
||||
SSANot => {
|
||||
self.param_one(instruction, |val_a| {
|
||||
val_a.simd_eq(VALUE_0).select(VALUE_1, VALUE_0)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAStop => return VALUE_0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,16 @@ pub(crate) fn compile_gradient_function(
|
||||
tape: &SSATape,
|
||||
types: SpirVTypes,
|
||||
function_id: Option<spirv::Word>,
|
||||
pointers_in: bool,
|
||||
) {
|
||||
let gradient_fn_type = b.type_function(types.vec4, vec![types.vec4p]);
|
||||
let gradient_fn_type = b.type_function(
|
||||
types.vec4,
|
||||
if pointers_in {
|
||||
vec![types.vec4p]
|
||||
} else {
|
||||
vec![types.vec4]
|
||||
},
|
||||
);
|
||||
let jit_string = b.string("Gradient JIT");
|
||||
let _scene = b
|
||||
.begin_function(
|
||||
@@ -25,11 +33,17 @@ pub(crate) fn compile_gradient_function(
|
||||
gradient_fn_type,
|
||||
)
|
||||
.unwrap();
|
||||
let pos_p = b.function_parameter(types.vec4p).unwrap();
|
||||
let pos_p = b
|
||||
.function_parameter(if pointers_in { types.vec4p } else { types.vec4 })
|
||||
.unwrap();
|
||||
|
||||
b.begin_block(None).unwrap();
|
||||
|
||||
let pos = b.load(types.vec4, None, pos_p, None, []).unwrap();
|
||||
let pos = if pointers_in {
|
||||
b.load(types.vec4, None, pos_p, None, []).unwrap()
|
||||
} else {
|
||||
pos_p
|
||||
};
|
||||
|
||||
let mut mapping = HashMap::<u32, u32>::new();
|
||||
|
||||
@@ -115,7 +129,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.composite_construct(types.vec4, None, vec![zero, zero, zero, zero])
|
||||
.unwrap();
|
||||
b.ret_value(out).unwrap();
|
||||
},
|
||||
}
|
||||
SSAReturn => {
|
||||
let value = input_resolve(types.float, b, &mapping, instruction.inputs[0]);
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
@@ -123,7 +137,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.composite_construct(types.vec4, None, vec![value, zero, zero, zero])
|
||||
.unwrap();
|
||||
b.ret_value(out).unwrap();
|
||||
},
|
||||
}
|
||||
SSAPosition => {
|
||||
mapping.insert(
|
||||
instruction.outputs[0],
|
||||
@@ -141,7 +155,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction.outputs[3],
|
||||
b.composite_extract(types.float, None, pos, [3]).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAdd => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -150,7 +164,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_add(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASub => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -159,7 +173,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_sub(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMul => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -168,7 +182,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_mul(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSADiv => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -177,7 +191,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_div(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMod => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -186,7 +200,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_mod(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAtan2 => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -204,7 +218,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMin => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -222,7 +236,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMinMaterial => todo!(),
|
||||
SSAMax => {
|
||||
param_two(
|
||||
@@ -241,7 +255,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMaxMaterial => todo!(),
|
||||
SSADot => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
@@ -264,7 +278,7 @@ pub(crate) fn compile_gradient_function(
|
||||
b.dot(types.float, None, val_a, val_b).unwrap()
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], dot);
|
||||
},
|
||||
}
|
||||
SSALength => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| {
|
||||
@@ -287,7 +301,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], length);
|
||||
},
|
||||
}
|
||||
SSADistance => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| {
|
||||
@@ -316,18 +330,18 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], distance);
|
||||
},
|
||||
}
|
||||
SSARecip => {
|
||||
param_one(types.float, 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).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSANegate => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.f_negate(types.float, None, val_a).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSARound => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -339,7 +353,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAbs => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -351,7 +365,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFloor => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -363,7 +377,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACeil => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -375,7 +389,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFract => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -387,7 +401,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASin => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -399,7 +413,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACos => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -411,7 +425,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSATan => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -423,7 +437,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAsin => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -435,7 +449,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAcos => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -447,7 +461,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAtan => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -459,7 +473,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAExp => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -471,7 +485,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSALog => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -483,7 +497,7 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASqrt => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -495,18 +509,18 @@ pub(crate) fn compile_gradient_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASquare => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.f_mul(types.float, None, val_a, val_a).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACube => {
|
||||
param_one(types.float, 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()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMin => {
|
||||
param_three(types.float, b, &mut mapping, instruction, |b, d1, d2, k| {
|
||||
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
|
||||
@@ -539,7 +553,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap();
|
||||
b.f_sub(types.float, None, mix, kh_negh).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMax => {
|
||||
param_three(types.float, b, &mut mapping, instruction, |b, d1, d2, k| {
|
||||
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
|
||||
@@ -573,7 +587,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap();
|
||||
b.f_add(types.float, None, mix, kh_negh).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMinMaterial => todo!(),
|
||||
SSASmoothMaxMaterial => todo!(),
|
||||
SSAClamp => {
|
||||
@@ -593,7 +607,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMix => {
|
||||
param_three(
|
||||
types.float,
|
||||
@@ -611,7 +625,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAFMA => {
|
||||
param_three(
|
||||
types.float,
|
||||
@@ -629,7 +643,7 @@ pub(crate) fn compile_gradient_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFSphere => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -653,7 +667,7 @@ pub(crate) fn compile_gradient_function(
|
||||
let sphere = b.f_sub(types.float, None, length, radius).unwrap();
|
||||
|
||||
mapping.insert(instruction.outputs[0], sphere);
|
||||
},
|
||||
}
|
||||
SSASDFBox => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -742,7 +756,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction.outputs[0],
|
||||
b.f_add(types.float, None, length, min).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFTorus => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -787,7 +801,7 @@ pub(crate) fn compile_gradient_function(
|
||||
instruction.outputs[0],
|
||||
b.f_sub(types.float, None, length, rad2).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSACompare => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -813,7 +827,7 @@ pub(crate) fn compile_gradient_function(
|
||||
select_eq
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAnd => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -826,7 +840,7 @@ pub(crate) fn compile_gradient_function(
|
||||
b.select(types.float, None, equal, val_a, val_b).unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAOr => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -839,7 +853,7 @@ pub(crate) fn compile_gradient_function(
|
||||
b.select(types.float, None, equal, val_b, val_a).unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSANot => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
@@ -847,7 +861,7 @@ pub(crate) fn compile_gradient_function(
|
||||
let equal = b.f_ord_equal(types.bool, None, val_a, zero).unwrap();
|
||||
b.select(types.float, None, equal, one, zero).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
b.end_function().unwrap();
|
||||
|
||||
@@ -12,8 +12,16 @@ pub(crate) fn compile_interval_function(
|
||||
tape: &SSATape,
|
||||
types: SpirVTypes,
|
||||
function_id: Option<spirv::Word>,
|
||||
pointers_in: bool,
|
||||
) {
|
||||
let interval_fn_type = b.type_function(types.vec2, vec![types.vec4p, types.vec4p]);
|
||||
let interval_fn_type = b.type_function(
|
||||
types.vec2,
|
||||
if pointers_in {
|
||||
vec![types.vec4p, types.vec4p]
|
||||
} else {
|
||||
vec![types.vec4, types.vec4]
|
||||
},
|
||||
);
|
||||
let jit_string = b.string("Interval JIT");
|
||||
let _scene = b
|
||||
.begin_function(
|
||||
@@ -26,13 +34,23 @@ pub(crate) fn compile_interval_function(
|
||||
interval_fn_type,
|
||||
)
|
||||
.unwrap();
|
||||
let pos_low = b.function_parameter(types.vec4p).unwrap();
|
||||
let pos_high = b.function_parameter(types.vec4p).unwrap();
|
||||
let pos_low = b
|
||||
.function_parameter(if pointers_in { types.vec4p } else { types.vec4 })
|
||||
.unwrap();
|
||||
let pos_high = b
|
||||
.function_parameter(if pointers_in { types.vec4p } else { types.vec4 })
|
||||
.unwrap();
|
||||
|
||||
b.begin_block(None).unwrap();
|
||||
|
||||
let pos_low = b.load(types.vec4, None, pos_low, None, []).unwrap();
|
||||
let pos_high = b.load(types.vec4, None, pos_high, None, []).unwrap();
|
||||
let (pos_low, pos_high) = if pointers_in {
|
||||
(
|
||||
b.load(types.vec4, None, pos_low, None, []).unwrap(),
|
||||
b.load(types.vec4, None, pos_high, None, []).unwrap(),
|
||||
)
|
||||
} else {
|
||||
(pos_low, pos_high)
|
||||
};
|
||||
|
||||
let mut mapping = HashMap::<u32, (u32, u32)>::new();
|
||||
|
||||
@@ -53,7 +71,7 @@ pub(crate) fn compile_interval_function(
|
||||
SSAInput::Constant(c) => {
|
||||
let constant = b.constant_bit32(float, c.to_bits());
|
||||
(constant, constant)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,10 +330,22 @@ pub(crate) fn compile_interval_function(
|
||||
let gt = b.f_ord_greater_than(bool, None, v.1, zero_const).unwrap();
|
||||
let both = b.logical_and(bool, None, lt, gt).unwrap();
|
||||
let abs_l = b
|
||||
.ext_inst(float, None, glsl, spirv::GlslStd450Op::FAbs as u32, [IdRef(v.0)])
|
||||
.ext_inst(
|
||||
float,
|
||||
None,
|
||||
glsl,
|
||||
spirv::GlslStd450Op::FAbs as u32,
|
||||
[IdRef(v.0)],
|
||||
)
|
||||
.unwrap();
|
||||
let abs_h = b
|
||||
.ext_inst(float, None, glsl, spirv::GlslStd450Op::FAbs as u32, [IdRef(v.1)])
|
||||
.ext_inst(
|
||||
float,
|
||||
None,
|
||||
glsl,
|
||||
spirv::GlslStd450Op::FAbs as u32,
|
||||
[IdRef(v.1)],
|
||||
)
|
||||
.unwrap();
|
||||
let min = b
|
||||
.ext_inst(
|
||||
@@ -334,10 +364,22 @@ pub(crate) fn compile_interval_function(
|
||||
.iter()
|
||||
.map(|v| {
|
||||
let abs_l = b
|
||||
.ext_inst(float, None, glsl, spirv::GlslStd450Op::FAbs as u32, [IdRef(v.0)])
|
||||
.ext_inst(
|
||||
float,
|
||||
None,
|
||||
glsl,
|
||||
spirv::GlslStd450Op::FAbs as u32,
|
||||
[IdRef(v.0)],
|
||||
)
|
||||
.unwrap();
|
||||
let abs_h = b
|
||||
.ext_inst(float, None, glsl, spirv::GlslStd450Op::FAbs as u32, [IdRef(v.1)])
|
||||
.ext_inst(
|
||||
float,
|
||||
None,
|
||||
glsl,
|
||||
spirv::GlslStd450Op::FAbs as u32,
|
||||
[IdRef(v.1)],
|
||||
)
|
||||
.unwrap();
|
||||
b.ext_inst(
|
||||
float,
|
||||
@@ -361,7 +403,13 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap();
|
||||
let xy_sum = b.f_add(float, None, x, y).unwrap();
|
||||
let sqrt_low = b
|
||||
.ext_inst(float, None, glsl, spirv::GlslStd450Op::Sqrt as u32, [IdRef(xy_sum)])
|
||||
.ext_inst(
|
||||
float,
|
||||
None,
|
||||
glsl,
|
||||
spirv::GlslStd450Op::Sqrt as u32,
|
||||
[IdRef(xy_sum)],
|
||||
)
|
||||
.unwrap();
|
||||
let x = b
|
||||
.f_mul(float, None, val_a_uppers[0], val_a_uppers[0])
|
||||
@@ -371,10 +419,16 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap();
|
||||
let xy_sum = b.f_add(float, None, x, y).unwrap();
|
||||
let sqrt_high = b
|
||||
.ext_inst(float, None, glsl, spirv::GlslStd450Op::Sqrt as u32, [IdRef(xy_sum)])
|
||||
.ext_inst(
|
||||
float,
|
||||
None,
|
||||
glsl,
|
||||
spirv::GlslStd450Op::Sqrt as u32,
|
||||
[IdRef(xy_sum)],
|
||||
)
|
||||
.unwrap();
|
||||
(sqrt_low, sqrt_high)
|
||||
},
|
||||
}
|
||||
3 => {
|
||||
let x = b
|
||||
.f_mul(float, None, val_a_lowers[0], val_a_lowers[0])
|
||||
@@ -417,7 +471,7 @@ pub(crate) fn compile_interval_function(
|
||||
)
|
||||
.unwrap();
|
||||
(sqrt_low, sqrt_high)
|
||||
},
|
||||
}
|
||||
4 => {
|
||||
let x = b
|
||||
.f_mul(float, None, val_a_lowers[0], val_a_lowers[0])
|
||||
@@ -468,7 +522,7 @@ pub(crate) fn compile_interval_function(
|
||||
)
|
||||
.unwrap();
|
||||
(sqrt_low, sqrt_high)
|
||||
},
|
||||
}
|
||||
_ => unreachable!("Invalid opcode size {}", opcode_size),
|
||||
}
|
||||
}
|
||||
@@ -783,14 +837,14 @@ pub(crate) fn compile_interval_function(
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
let zero_vec2 = b.constant_composite(types.vec2, [zero, zero]);
|
||||
b.ret_value(zero_vec2).unwrap();
|
||||
},
|
||||
}
|
||||
SSAReturn => {
|
||||
let value = input_resolve(types.float, b, &mapping, instruction.inputs[0]);
|
||||
let value_vec2 = b
|
||||
.composite_construct(types.vec2, None, [value.0, value.1])
|
||||
.unwrap();
|
||||
b.ret_value(value_vec2).unwrap();
|
||||
},
|
||||
}
|
||||
SSAPosition => {
|
||||
let pos_low_x = b
|
||||
.composite_extract(types.float, None, pos_low, [0])
|
||||
@@ -820,7 +874,7 @@ pub(crate) fn compile_interval_function(
|
||||
mapping.insert(instruction.outputs[1], (pos_low_y, pos_high_y));
|
||||
mapping.insert(instruction.outputs[2], (pos_low_z, pos_high_z));
|
||||
mapping.insert(instruction.outputs[3], (pos_low_w, pos_high_w));
|
||||
},
|
||||
}
|
||||
SSAAdd => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -829,7 +883,7 @@ pub(crate) fn compile_interval_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| add(types.float, b, val_a, val_b),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASub => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -838,7 +892,7 @@ pub(crate) fn compile_interval_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| sub(types.float, b, val_a, val_b),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMul => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -847,7 +901,7 @@ pub(crate) fn compile_interval_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| multiply(types.float, b, types.glsl, val_a, val_b),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSADiv => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -856,7 +910,7 @@ pub(crate) fn compile_interval_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| divide(types.float, b, types.glsl, val_a, val_b),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMod => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -929,7 +983,7 @@ pub(crate) fn compile_interval_function(
|
||||
(low, high)
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAtan2 => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -944,7 +998,7 @@ pub(crate) fn compile_interval_function(
|
||||
(npi_const, pi_const)
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMin => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -964,7 +1018,7 @@ pub(crate) fn compile_interval_function(
|
||||
.0
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMinMaterial => todo!(),
|
||||
SSAMax => {
|
||||
param_two(
|
||||
@@ -985,7 +1039,7 @@ pub(crate) fn compile_interval_function(
|
||||
.0
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMaxMaterial => todo!(),
|
||||
SSADot => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
@@ -1004,14 +1058,14 @@ pub(crate) fn compile_interval_function(
|
||||
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
|
||||
let muly = multiply(types.float, b, types.glsl, val_a[1], val_b[1]);
|
||||
add(types.float, b, mulx, muly)
|
||||
},
|
||||
}
|
||||
3 => {
|
||||
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
|
||||
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);
|
||||
add(types.float, b, accum, mulz)
|
||||
},
|
||||
}
|
||||
4 => {
|
||||
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
|
||||
let muly = multiply(types.float, b, types.glsl, val_a[1], val_b[1]);
|
||||
@@ -1020,11 +1074,11 @@ pub(crate) fn compile_interval_function(
|
||||
let accum = add(types.float, b, mulx, muly);
|
||||
let accum = add(types.float, b, accum, mulz);
|
||||
add(types.float, b, accum, mulw)
|
||||
},
|
||||
}
|
||||
_ => unreachable!("Invalid opcode size {}", instruction.opcode.size),
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], dot);
|
||||
},
|
||||
}
|
||||
SSALength | SSADistance => {
|
||||
let mut val_a = (0..instruction.opcode.size)
|
||||
.map(|i| {
|
||||
@@ -1057,7 +1111,7 @@ pub(crate) fn compile_interval_function(
|
||||
&val_a,
|
||||
),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSARecip => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
|
||||
@@ -1066,12 +1120,12 @@ pub(crate) fn compile_interval_function(
|
||||
b.f_div(types.float, None, one, val_a.0).unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSANegate => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
negate(types.float, b, val_a)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSARound => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1093,12 +1147,12 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAbs => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
abs(types.float, b, types.bool, types.glsl, val_a)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFloor => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1120,7 +1174,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACeil => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1142,7 +1196,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFract => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
@@ -1174,7 +1228,7 @@ pub(crate) fn compile_interval_function(
|
||||
b.select(types.float, None, ge1, one, fract_high).unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASin | SSACos => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let pi_2 =
|
||||
@@ -1277,7 +1331,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap();
|
||||
(lower, upper)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSATan => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let pi = b.constant_bit32(types.float, (std::f32::consts::PI).to_bits());
|
||||
@@ -1313,7 +1367,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAsin => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
|
||||
@@ -1351,7 +1405,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAcos => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
|
||||
@@ -1389,7 +1443,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAtan => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1411,7 +1465,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAExp => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1433,7 +1487,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSALog => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1455,7 +1509,7 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASqrt => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
(
|
||||
@@ -1477,12 +1531,12 @@ pub(crate) fn compile_interval_function(
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASquare => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
square(types.float, b, types.bool, types.glsl, val_a)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACube => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let squ_lower = b.f_mul(types.float, None, val_a.0, val_a.0).unwrap();
|
||||
@@ -1492,7 +1546,7 @@ pub(crate) fn compile_interval_function(
|
||||
b.f_mul(types.float, None, val_a.1, squ_upper).unwrap(),
|
||||
)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMin => {
|
||||
param_three(types.float, b, &mut mapping, instruction, |b, d1, d2, k| {
|
||||
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
|
||||
@@ -1532,7 +1586,7 @@ pub(crate) fn compile_interval_function(
|
||||
let mix = mix(types.float, b, types.glsl, d2, d1, h);
|
||||
sub(types.float, b, mix, kh_negh)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMax => {
|
||||
param_three(types.float, b, &mut mapping, instruction, |b, d1, d2, k| {
|
||||
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
|
||||
@@ -1573,7 +1627,7 @@ pub(crate) fn compile_interval_function(
|
||||
let mix = mix(types.float, b, types.glsl, d2, negd1, h);
|
||||
add(types.float, b, mix, kh_negh)
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMinMaterial => todo!(),
|
||||
SSASmoothMaxMaterial => todo!(),
|
||||
SSAClamp => {
|
||||
@@ -1603,7 +1657,7 @@ pub(crate) fn compile_interval_function(
|
||||
)
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMix => {
|
||||
param_three(
|
||||
types.float,
|
||||
@@ -1612,7 +1666,7 @@ pub(crate) fn compile_interval_function(
|
||||
instruction,
|
||||
|b, val_a, val_b, val_c| mix(types.float, b, types.glsl, val_a, val_b, val_c),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAFMA => {
|
||||
param_three(
|
||||
types.float,
|
||||
@@ -1624,7 +1678,7 @@ pub(crate) fn compile_interval_function(
|
||||
add(types.float, b, mul, val_c)
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFSphere => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -1638,7 +1692,7 @@ pub(crate) fn compile_interval_function(
|
||||
let sphere = sub(types.float, b, length, radius);
|
||||
|
||||
mapping.insert(instruction.outputs[0], sphere);
|
||||
},
|
||||
}
|
||||
SSASDFBox => {
|
||||
let abs_pos = (0..3)
|
||||
.map(|i| {
|
||||
@@ -1723,7 +1777,7 @@ pub(crate) fn compile_interval_function(
|
||||
.0;
|
||||
|
||||
mapping.insert(instruction.outputs[0], add(types.float, b, length, min));
|
||||
},
|
||||
}
|
||||
SSASDFTorus => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -1767,7 +1821,7 @@ pub(crate) fn compile_interval_function(
|
||||
);
|
||||
|
||||
mapping.insert(instruction.outputs[0], sub(types.float, b, length, rad2));
|
||||
},
|
||||
}
|
||||
SSACompare => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -1797,7 +1851,7 @@ pub(crate) fn compile_interval_function(
|
||||
(low, high)
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAnd => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -1817,7 +1871,7 @@ pub(crate) fn compile_interval_function(
|
||||
.0
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAOr => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -1837,7 +1891,7 @@ pub(crate) fn compile_interval_function(
|
||||
.0
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSANot => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
@@ -1860,7 +1914,7 @@ pub(crate) fn compile_interval_function(
|
||||
let upper = b.select(types.float, None, contains, one, zero).unwrap();
|
||||
(lower, upper)
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
b.end_function().unwrap();
|
||||
|
||||
@@ -11,8 +11,16 @@ pub(crate) fn compile_point_function(
|
||||
tape: &SSATape,
|
||||
types: SpirVTypes,
|
||||
function_id: Option<spirv::Word>,
|
||||
pointers_in: bool,
|
||||
) {
|
||||
let point_fn_type = b.type_function(types.float, vec![types.vec4p]);
|
||||
let point_fn_type = b.type_function(
|
||||
types.float,
|
||||
if pointers_in {
|
||||
vec![types.vec4p]
|
||||
} else {
|
||||
vec![types.vec4]
|
||||
},
|
||||
);
|
||||
let jit_string = b.string("Point JIT");
|
||||
let _scene = b
|
||||
.begin_function(
|
||||
@@ -25,11 +33,17 @@ pub(crate) fn compile_point_function(
|
||||
point_fn_type,
|
||||
)
|
||||
.unwrap();
|
||||
let pos_p = b.function_parameter(types.vec4p).unwrap();
|
||||
let pos_p = b
|
||||
.function_parameter(if pointers_in { types.vec4p } else { types.vec4 })
|
||||
.unwrap();
|
||||
|
||||
b.begin_block(None).unwrap();
|
||||
|
||||
let pos = b.load(types.vec4, None, pos_p, None, []).unwrap();
|
||||
let pos = if pointers_in {
|
||||
b.load(types.vec4, None, pos_p, None, []).unwrap()
|
||||
} else {
|
||||
pos_p
|
||||
};
|
||||
|
||||
let mut mapping = HashMap::<u32, u32>::new();
|
||||
|
||||
@@ -112,11 +126,11 @@ pub(crate) fn compile_point_function(
|
||||
SSAStop => {
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
b.ret_value(zero).unwrap();
|
||||
},
|
||||
}
|
||||
SSAReturn => {
|
||||
let value = input_resolve(types.float, b, &mapping, instruction.inputs[0]);
|
||||
b.ret_value(value).unwrap();
|
||||
},
|
||||
}
|
||||
SSAPosition => {
|
||||
mapping.insert(
|
||||
instruction.outputs[0],
|
||||
@@ -134,7 +148,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction.outputs[3],
|
||||
b.composite_extract(types.float, None, pos, [3]).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAdd => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -143,7 +157,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_add(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASub => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -152,7 +166,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_sub(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMul => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -161,7 +175,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_mul(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSADiv => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -170,7 +184,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_div(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMod => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -179,7 +193,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction,
|
||||
|b, val_a, val_b| b.f_mod(types.float, None, val_a, val_b).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAtan2 => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -197,7 +211,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMin => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -215,7 +229,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMinMaterial => todo!(),
|
||||
SSAMax => {
|
||||
param_two(
|
||||
@@ -234,7 +248,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMaxMaterial => todo!(),
|
||||
SSADot => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
@@ -257,7 +271,7 @@ pub(crate) fn compile_point_function(
|
||||
b.dot(types.float, None, val_a, val_b).unwrap()
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], dot);
|
||||
},
|
||||
}
|
||||
SSALength => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| {
|
||||
@@ -280,7 +294,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], length);
|
||||
},
|
||||
}
|
||||
SSADistance => {
|
||||
let val_a = (0..instruction.opcode.size)
|
||||
.map(|i| {
|
||||
@@ -309,18 +323,18 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
};
|
||||
mapping.insert(instruction.outputs[0], distance);
|
||||
},
|
||||
}
|
||||
SSARecip => {
|
||||
param_one(types.float, 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).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSANegate => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.f_negate(types.float, None, val_a).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSARound => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -332,7 +346,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAbs => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -344,7 +358,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFloor => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -356,7 +370,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACeil => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -368,7 +382,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAFract => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -380,7 +394,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASin => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -392,7 +406,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACos => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -404,7 +418,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSATan => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -416,7 +430,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAsin => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -428,7 +442,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAcos => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -440,7 +454,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAAtan => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -452,7 +466,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSAExp => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -464,7 +478,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSALog => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -476,7 +490,7 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASqrt => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.ext_inst(
|
||||
@@ -488,18 +502,18 @@ pub(crate) fn compile_point_function(
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASquare => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
b.f_mul(types.float, None, val_a, val_a).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSACube => {
|
||||
param_one(types.float, 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()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMin => {
|
||||
param_three(types.float, b, &mut mapping, instruction, |b, d1, d2, k| {
|
||||
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
|
||||
@@ -532,7 +546,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap();
|
||||
b.f_sub(types.float, None, mix, kh_negh).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMax => {
|
||||
param_three(types.float, b, &mut mapping, instruction, |b, d1, d2, k| {
|
||||
let half_const = b.constant_bit32(types.float, (0.5f32).to_bits());
|
||||
@@ -566,7 +580,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap();
|
||||
b.f_add(types.float, None, mix, kh_negh).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
SSASmoothMinMaterial => todo!(),
|
||||
SSASmoothMaxMaterial => todo!(),
|
||||
SSAClamp => {
|
||||
@@ -586,7 +600,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAMix => {
|
||||
param_three(
|
||||
types.float,
|
||||
@@ -604,7 +618,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAFMA => {
|
||||
param_three(
|
||||
types.float,
|
||||
@@ -622,7 +636,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFSphere => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -645,7 +659,7 @@ pub(crate) fn compile_point_function(
|
||||
let sphere = b.f_sub(types.float, None, length, radius).unwrap();
|
||||
|
||||
mapping.insert(instruction.outputs[0], sphere);
|
||||
},
|
||||
}
|
||||
SSASDFBox => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -734,7 +748,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction.outputs[0],
|
||||
b.f_add(types.float, None, length, min).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSASDFTorus => {
|
||||
let pos_part = (0..3)
|
||||
.map(|i| {
|
||||
@@ -779,7 +793,7 @@ pub(crate) fn compile_point_function(
|
||||
instruction.outputs[0],
|
||||
b.f_sub(types.float, None, length, rad2).unwrap(),
|
||||
);
|
||||
},
|
||||
}
|
||||
SSACompare => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -803,7 +817,7 @@ pub(crate) fn compile_point_function(
|
||||
.unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAAnd => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -816,7 +830,7 @@ pub(crate) fn compile_point_function(
|
||||
b.select(types.float, None, equal, val_a, val_b).unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSAOr => {
|
||||
param_two(
|
||||
types.float,
|
||||
@@ -829,7 +843,7 @@ pub(crate) fn compile_point_function(
|
||||
b.select(types.float, None, equal, val_b, val_a).unwrap()
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
SSANot => {
|
||||
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
|
||||
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
|
||||
@@ -837,7 +851,7 @@ pub(crate) fn compile_point_function(
|
||||
let equal = b.f_ord_equal(types.bool, None, val_a, zero).unwrap();
|
||||
b.select(types.float, None, equal, one, zero).unwrap()
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
b.end_function().unwrap();
|
||||
|
||||
@@ -552,7 +552,11 @@ impl SSATape {
|
||||
gpu_tape
|
||||
}
|
||||
|
||||
pub fn compile_to_spirv(&self, module: Option<Module>) -> rspirv::dr::Module {
|
||||
pub fn compile_to_spirv(
|
||||
&self,
|
||||
module: Option<Module>,
|
||||
pointers_in: bool,
|
||||
) -> rspirv::dr::Module {
|
||||
let with_module = module.is_some();
|
||||
let mut b = if let Some(module) = module {
|
||||
rspirv::dr::Builder::new_from_module(module)
|
||||
@@ -610,6 +614,7 @@ impl SSATape {
|
||||
} else {
|
||||
None
|
||||
},
|
||||
pointers_in,
|
||||
);
|
||||
|
||||
// Manually fix the header bounds
|
||||
@@ -627,6 +632,7 @@ impl SSATape {
|
||||
} else {
|
||||
None
|
||||
},
|
||||
pointers_in,
|
||||
);
|
||||
|
||||
// Manually fix the header bounds
|
||||
@@ -644,6 +650,7 @@ impl SSATape {
|
||||
} else {
|
||||
None
|
||||
},
|
||||
pointers_in,
|
||||
);
|
||||
|
||||
let module = b.module();
|
||||
|
||||
Reference in New Issue
Block a user