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