Compare commits

...

2 Commits

Author SHA1 Message Date
molive ee0e0c2b5f fmt clippy 2025-12-26 00:50:30 +00:00
molive 18fdec939c no warnings or errors 2025-12-26 00:28:18 +00:00
15 changed files with 188 additions and 369 deletions
Generated
+25 -25
View File
@@ -318,7 +318,7 @@ checksum = "cb9f6e1368bd4621d2c86baa7e37de77a938adf5221e5dd3d6133340101b309e"
dependencies = [
"bitflags 2.10.0",
"polling",
"rustix 1.1.2",
"rustix 1.1.3",
"slab",
"tracing",
]
@@ -342,7 +342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa"
dependencies = [
"calloop 0.14.3",
"rustix 1.1.2",
"rustix 1.1.3",
"wayland-backend",
"wayland-client",
]
@@ -859,7 +859,7 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
dependencies = [
"rustix 1.1.2",
"rustix 1.1.3",
"windows-link",
]
@@ -1050,7 +1050,7 @@ dependencies = [
"rgb",
"tiff",
"zune-core 0.5.0",
"zune-jpeg 0.5.7",
"zune-jpeg 0.5.8",
]
[[package]]
@@ -1121,9 +1121,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.15"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
checksum = "7ee5b5339afb4c41626dde77b7a611bd4f2c202b897852b4bcf5d03eddc61010"
[[package]]
name = "jni"
@@ -1943,7 +1943,7 @@ dependencies = [
"concurrent-queue",
"hermit-abi",
"pin-project-lite",
"rustix 1.1.2",
"rustix 1.1.3",
"windows-sys 0.61.2",
]
@@ -2246,9 +2246,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "1.1.2"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
dependencies = [
"bitflags 2.10.0",
"errno",
@@ -2263,12 +2263,6 @@ version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "ryu"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "same-file"
version = "1.0.6"
@@ -2335,15 +2329,15 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.145"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
checksum = "6af14725505314343e673e9ecb7cd7e8a36aa9791eb936235a3567cc31447ae4"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
"serde_core",
"zmij",
]
[[package]]
@@ -2455,7 +2449,7 @@ dependencies = [
"libc",
"log",
"memmap2",
"rustix 1.1.2",
"rustix 1.1.3",
"thiserror 2.0.17",
"wayland-backend",
"wayland-client",
@@ -2983,7 +2977,7 @@ checksum = "673a33c33048a5ade91a6b139580fa174e19fb0d23f396dca9fa15f2e1e49b35"
dependencies = [
"cc",
"downcast-rs",
"rustix 1.1.2",
"rustix 1.1.3",
"scoped-tls",
"smallvec",
"wayland-sys",
@@ -2996,7 +2990,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66a47e840dc20793f2264eb4b3e4ecb4b75d91c0dd4af04b456128e0bdd449d"
dependencies = [
"bitflags 2.10.0",
"rustix 1.1.2",
"rustix 1.1.3",
"wayland-backend",
"wayland-scanner",
]
@@ -3018,7 +3012,7 @@ version = "0.31.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447ccc440a881271b19e9989f75726d60faa09b95b0200a9b7eb5cc47c3eeb29"
dependencies = [
"rustix 1.1.2",
"rustix 1.1.3",
"wayland-client",
"xcursor",
]
@@ -3493,7 +3487,7 @@ dependencies = [
"libc",
"libloading",
"once_cell",
"rustix 1.1.2",
"rustix 1.1.3",
"x11rb-protocol",
]
@@ -3643,6 +3637,12 @@ dependencies = [
"syn",
]
[[package]]
name = "zmij"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0095ecd462946aa3927d9297b63ef82fb9a5316d7a37d134eeb36e58228615a"
[[package]]
name = "zune-core"
version = "0.4.12"
@@ -3675,9 +3675,9 @@ dependencies = [
[[package]]
name = "zune-jpeg"
version = "0.5.7"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d915729b0e7d5fe35c2f294c5dc10b30207cc637920e5b59077bfa3da63f28"
checksum = "e35aee689668bf9bd6f6f3a6c60bb29ba1244b3b43adfd50edd554a371da37d5"
dependencies = [
"zune-core 0.5.0",
]
+3 -4
View File
@@ -1,4 +1,4 @@
use std::{fs::read_dir, io::Write, process::Command};
use std::{fs::read_dir, process::Command};
fn main() {
//let mut output = std::fs::File::create("output.txt").unwrap();
@@ -8,8 +8,8 @@ fn main() {
let paths = read_dir("src/shaders").unwrap();
for path in paths {
if let Ok(path) = path {
if path
if let Ok(path) = path
&& path
.path()
.extension()
.map(|ext| ext == "glsl")
@@ -20,7 +20,6 @@ fn main() {
// path.path().display()).unwrap();
}
}
}
Command::new("python3")
.arg("assemble_trace.py")
+37 -44
View File
@@ -10,8 +10,8 @@ const DEFAULT_SUBDIVISION: u32 = 16;
const MAXIMUM_SUBDIVISION: u32 = 64;
const MINUMUM_SUBDIVISION: u32 = 8;
const RUN_STANDARD_PIPELINE: bool = false;
const RUN_RT_PIPELINE: bool = true;
const RUN_STANDARD_PIPELINE: bool = true;
const RUN_RT_PIPELINE: bool = false;
use std::{
error::Error,
@@ -417,7 +417,7 @@ impl App {
Format::D16_UNORM_S8_UINT,
];
let depth_format = (if IGNORE_STENCIL {
let depth_format = *(if IGNORE_STENCIL {
DEPTH_FORMAT_ORDERING_IGNORE_STENCIL.iter()
} else {
DEPTH_FORMAT_ORDERING.iter()
@@ -430,8 +430,7 @@ impl App {
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
})
.next()
.expect("Could not find suitable depth format!")
.clone();
.expect("Could not find suitable depth format!");
info!("Using depth format {:?}", depth_format);
@@ -619,12 +618,9 @@ impl App {
move |res: Result<notify::Event, notify::Error>| match res {
Ok(event) => {
//info!("event: {:?}", event);
match event.kind {
notify::EventKind::Modify(_) => {
if let notify::EventKind::Modify(_) = event.kind {
info!("event: {:?}", event);
watcher_glsl_changed.store(true, std::sync::atomic::Ordering::Relaxed);
},
_ => {},
}
},
Err(e) => error!("watch error: {:?}", e),
@@ -758,7 +754,8 @@ impl ApplicationHandler for App {
.surface_present_modes(&surface, Default::default())
.unwrap();
let present_mode = present_modes
present_modes
.into_iter()
.min_by_key(|p| {
// We assign a lower score to device types that are likely to be
@@ -771,8 +768,7 @@ impl ApplicationHandler for App {
_ => 4,
}
})
.unwrap();
present_mode
.unwrap()
};
info!("Using present mode {:?}.", present_mode);
@@ -965,7 +961,7 @@ impl ApplicationHandler for App {
let viewport = Viewport {
offset: [0.0, window_size.height as f32],
extent: [window_size.width as f32, window_size.height as f32 * -1.],
extent: [window_size.width as f32, -(window_size.height as f32)],
depth_range: 0.0..=1.0,
};
@@ -1076,15 +1072,14 @@ impl ApplicationHandler for App {
_device_id: winit::event::DeviceId,
event: DeviceEvent,
) {
if let DeviceEvent::MouseMotion { delta } = &event {
if self.cstate.looking {
if let DeviceEvent::MouseMotion { delta } = &event
&& self.cstate.looking {
self.cstate.forward.x += delta.1 as f32 * self.gstate.cursor_sensitivity * 0.3;
self.cstate.forward.y += delta.0 as f32 * self.gstate.cursor_sensitivity * 0.3;
self.cstate.forward.x += 360f32 % 360f32;
self.cstate.forward.y += 360f32 % 360f32;
}
}
}
fn window_event(
&mut self,
@@ -1095,11 +1090,10 @@ impl ApplicationHandler for App {
let rcx_clone = self.rcx.clone();
let mut rcx_lock = rcx_clone.lock().unwrap();
let rcx = rcx_lock.as_mut().unwrap();
if self.draw_gui {
if rcx.gui.update(&event) {
if self.draw_gui
&& rcx.gui.update(&event) {
return;
}
}
match &event {
WindowEvent::CloseRequested => {
event_loop.exit();
@@ -1168,7 +1162,7 @@ impl ApplicationHandler for App {
rcx.render_pass.clone(),
self.pipeline_cache.clone(),
rcx.shader_modules.clone(),
self.previous_debug.clone(),
self.previous_debug,
self.block_enable_allocator.clone(),
self.host_visible_allocator.clone(),
self.descriptor_set_allocator.clone(),
@@ -1207,32 +1201,32 @@ impl App {
if self.cstate.looking {
if self.cstate.keys.w {
self.cstate.position -=
Mat3::from_rotation_y(self.cstate.forward.y.to_radians() * -1.)
* Mat3::from_rotation_x(self.cstate.forward.x.to_radians() * -1.)
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::Z
* 0.01
* self.gstate.move_speed;
}
if self.cstate.keys.s {
self.cstate.position +=
Mat3::from_rotation_y(self.cstate.forward.y.to_radians() * -1.)
* Mat3::from_rotation_x(self.cstate.forward.x.to_radians() * -1.)
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::Z
* 0.01
* self.gstate.move_speed;
}
if self.cstate.keys.a {
self.cstate.position -=
Mat3::from_rotation_y(self.cstate.forward.y.to_radians() * -1.)
* Mat3::from_rotation_x(self.cstate.forward.x.to_radians() * -1.)
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::X
* 0.01
* self.gstate.move_speed;
}
if self.cstate.keys.d {
self.cstate.position +=
Mat3::from_rotation_y(self.cstate.forward.y.to_radians() * -1.)
* Mat3::from_rotation_x(self.cstate.forward.x.to_radians() * -1.)
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
* Vec3::X
* 0.01
* self.gstate.move_speed;
@@ -1267,13 +1261,13 @@ impl App {
self.cstate.position.z,
self.time,
],
specular: self.gstate.specular.into(),
specular_tint: self.gstate.specular_tint.into(),
sheen_tint: self.gstate.sheen_tint.into(),
sheen: self.gstate.sheen.into(),
clear_coat_gloss: self.gstate.clear_coat_gloss.into(),
subsurface: self.gstate.subsurface.into(),
clear_coat: self.gstate.clear_coat.into(),
specular: self.gstate.specular,
specular_tint: self.gstate.specular_tint,
sheen_tint: self.gstate.sheen_tint,
sheen: self.gstate.sheen,
clear_coat_gloss: self.gstate.clear_coat_gloss,
subsurface: self.gstate.subsurface,
clear_coat: self.gstate.clear_coat,
};
if self.cstate.looking {
@@ -1784,7 +1778,7 @@ impl App {
rcx.render_pass.clone(),
self.pipeline_cache.clone(),
rcx.shader_modules.clone(),
self.previous_debug.clone(),
self.previous_debug,
i,
))
.unwrap();
@@ -1863,7 +1857,7 @@ impl App {
rcx.render_pass.clone(),
self.pipeline_cache.clone(),
rcx.shader_modules.clone(),
self.previous_debug.clone(),
self.previous_debug,
self.block_enable_allocator.clone(),
self.host_visible_allocator.clone(),
self.descriptor_set_allocator.clone(),
@@ -1928,7 +1922,7 @@ impl App {
);
rcx.viewport.extent[0] = window_size.width as f32;
rcx.viewport.extent[1] = window_size.height as f32 * -1.;
rcx.viewport.extent[1] = -(window_size.height as f32);
rcx.viewport.offset[1] = window_size.height as f32;
rcx.recreate_swapchain = false;
@@ -1953,7 +1947,7 @@ impl App {
rcx.render_pass.clone(),
self.pipeline_cache.clone(),
rcx.shader_modules.clone(),
self.previous_debug.clone(),
self.previous_debug,
i,
))
.unwrap();
@@ -2108,7 +2102,7 @@ impl App {
.boxed();
}
if self.gstate.csg.len() > 0 {
if !self.gstate.csg.is_empty() {
self.add_commands_depth_pass(
&mut builder,
&push_constants,
@@ -2117,7 +2111,7 @@ impl App {
);
}
self.add_commands_primary_subpass(&mut builder);
if self.gstate.csg.len() > 0 {
if !self.gstate.csg.is_empty() {
self.add_commands_normal_pass(
&mut builder,
&push_constants,
@@ -2645,8 +2639,8 @@ where
}
fn dump_pipeline_cache(cache: Arc<PipelineCache>) {
if PIPELINE_CACHING {
if let Ok(data) = cache.get_data() {
if PIPELINE_CACHING
&& let Ok(data) = cache.get_data() {
info!("Dumping pipeline cache...");
let tmp_path = relpath("pipeline_cache.bin.tmp");
@@ -2660,7 +2654,6 @@ fn dump_pipeline_cache(cache: Arc<PipelineCache>) {
}
info!("Pipeline cache dump exit");
}
}
}
fn get_pipeline_cache(device: Arc<Device>) -> Arc<PipelineCache> {
+1 -1
View File
@@ -40,7 +40,7 @@ pub(crate) struct Mesh {
#[derive(Debug)]
pub(crate) struct CSG {
pub(crate) name: String,
pub(crate) seed: u64,
pub(crate) _seed: u64,
pub(crate) parts: SSATape,
pub(crate) pos: Vec3,
pub(crate) rot: Vec3,
+8 -13
View File
@@ -116,12 +116,12 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
let parts = create_csg(seed);
let trace_shader_module =
sdf_specialize_module(device.clone(), &parts, trace_module, &format!("trace"));
sdf_specialize_module(device.clone(), &parts, trace_module, "trace");
let normals_shader_module = sdf_specialize_module(
device.clone(),
&parts,
normals_module,
&format!("normals"),
"normals",
);
let (trace_pipeline, normals_pipeline) = deferred_pipelines_recompile(
@@ -135,7 +135,6 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
);
let enable_buffer: Vec<Subbuffer<Object>> = (0..frames)
.into_iter()
.map(|_| {
block_enable_allocator
.lock()
@@ -145,7 +144,6 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
})
.collect();
let enable_buffer_host_visible: Vec<Subbuffer<Object>> = (0..frames)
.into_iter()
.map(|_| {
host_visible_allocator
.lock()
@@ -157,7 +155,6 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
let trace_layout = trace_pipeline.layout().set_layouts()[1].clone();
let trace_descriptor_set = (0..frames)
.into_iter()
.map(|f| {
DescriptorSet::new(
descriptor_set_allocator.clone(),
@@ -174,7 +171,6 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
let normals_layout = normals_pipeline.layout().set_layouts()[1].clone();
let normals_descriptor_set = (0..frames)
.into_iter()
.map(|f| {
DescriptorSet::new(
descriptor_set_allocator.clone(),
@@ -191,7 +187,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
let csg = Arc::new(RwLock::new(CSG {
name: "example".to_string(),
seed,
_seed: seed,
parts,
pos: Vec3::ZERO,
rot: Vec3::ZERO,
@@ -276,13 +272,13 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
device.clone(),
&csg.parts,
trace_module,
&format!("trace"),
"trace",
);
csg.normals_shader_module = sdf_specialize_module(
device.clone(),
&csg.parts,
normals_module,
&format!("normals"),
"normals",
);
(csg.trace_pipeline, csg.normals_pipeline) = deferred_pipelines_recompile(
@@ -566,7 +562,7 @@ fn interval_check(
material,
subdivision_log2: csg.subdivision.ilog2(),
farplane: ((highest_corner - lowest_corner).length() / csg.subdivision as f32).into(),
colour: csg.colour.to_array().into(),
colour: csg.colour.to_array(),
roughness: csg.roughness,
metallic: csg.metallic,
};
@@ -673,14 +669,13 @@ fn sdf_specialize_module(
let module_as_bytes = assembled_module
.iter()
.cloned()
.map(u32::to_le_bytes)
.flatten()
.flat_map(u32::to_le_bytes)
.collect::<Vec<_>>();
if DUMP_SPV_TO_FILE {
File::create(format!("{name}.out.spv"))
.unwrap()
.write(&module_as_bytes)
.write_all(&module_as_bytes)
.unwrap();
}
+1
View File
@@ -177,6 +177,7 @@ pub enum InstructionSet {
OPPosition = ((1 * 64) + 63),
#[allow(non_snake_case)]
#[allow(dead_code)]
#[allow(clippy::erasing_op)]
/// Calculates the minimum of two Vec1s, and also carries over the relevant
/// material metadata.
OPMinMaterial = ((0 * 64) + 63),
+1 -21
View File
@@ -69,30 +69,10 @@ impl<'csg> IntervalInterpreter<'csg> {
}
}
fn param_four(
&mut self,
instruction: &SSAInstruction,
func: impl Fn(Interval, Interval, Interval, Interval) -> Interval,
) {
for i in 0..instruction.opcode.size as usize {
let val_a = self.load(instruction.inputs[i]);
let val_b = self.load(instruction.inputs[i + instruction.opcode.size as usize]);
let val_c = self.load(instruction.inputs[i + (instruction.opcode.size * 2) as usize]);
let val_d = self.load(instruction.inputs[i + (instruction.opcode.size * 3) as usize]);
self.store(instruction.outputs[i], func(val_a, val_b, val_c, val_d));
}
}
// cargo asm "tape-drive::interpreter::IntervalInterpreter::scene" --no-color
// --rust > scene.asm
pub fn scene(
&mut self,
px: Interval,
py: Interval,
pz: Interval,
time: Interval,
) -> Interval {
pub fn scene(&mut self, px: Interval, py: Interval, pz: Interval, time: Interval) -> Interval {
self.clear_stacks();
for instruction in &self.csg.tape {
-14
View File
@@ -68,20 +68,6 @@ impl<'csg> PointInterpreter<'csg> {
}
}
fn param_four(
&mut self,
instruction: &SSAInstruction,
func: impl Fn(Value, Value, Value, Value) -> Value,
) {
for i in 0..instruction.opcode.size as usize {
let val_a = self.load(instruction.inputs[i]);
let val_b = self.load(instruction.inputs[i + instruction.opcode.size as usize]);
let val_c = self.load(instruction.inputs[i + (instruction.opcode.size * 2) as usize]);
let val_d = self.load(instruction.inputs[i + (instruction.opcode.size * 3) as usize]);
self.store(instruction.outputs[i], func(val_a, val_b, val_c, val_d));
}
}
// cargo asm "tape-drive::interpreter::PointInterpreter::scene" --no-color
// --rust > scene.asm
+1 -1
View File
@@ -7,4 +7,4 @@ pub mod types;
pub mod vm;
const BYTECODE_IMITATES_GLSL: bool = false;
const DUMP_SPV_DIS_TO_FILE: bool = false;
const DUMP_SPV_DIS_TO_FILE: bool = true;
+80 -177
View File
@@ -111,43 +111,6 @@ pub(crate) fn compile_interval_function(
}
}
fn param_four(
float: u32,
b: &mut rspirv::dr::Builder,
mapping: &mut HashMap<u32, (u32, u32)>,
instruction: &SSAInstruction,
func: impl Fn(
&mut rspirv::dr::Builder,
(u32, u32),
(u32, u32),
(u32, u32),
(u32, u32),
) -> (u32, u32),
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_b = input_resolve(
float,
b,
&mapping,
instruction.inputs[i + instruction.opcode.size as usize],
);
let val_c = input_resolve(
float,
b,
&mapping,
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
);
let val_d = input_resolve(
float,
b,
&mapping,
instruction.inputs[i + (instruction.opcode.size as usize * 3)],
);
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c, val_d));
}
}
fn multiply(
float: u32,
b: &mut rspirv::dr::Builder,
@@ -964,7 +927,7 @@ pub(crate) fn compile_interval_function(
b,
&mut mapping,
instruction,
|b, val_a, val_b| {
|b, _val_a, _val_b| {
let pi_const =
b.constant_bit32(types.float, (std::f32::consts::PI).to_bits());
let npi_const =
@@ -1028,39 +991,29 @@ pub(crate) fn compile_interval_function(
.collect::<Vec<_>>();
let dot = match instruction.opcode.size {
1 => multiply(types.float, b, types.glsl, val_a[0], val_b[0]),
2 => add(
types.float,
b,
multiply(types.float, b, types.glsl, val_a[0], val_b[0]),
multiply(types.float, b, types.glsl, val_a[1], val_b[1]),
),
3 => add(
types.float,
b,
add(
types.float,
b,
multiply(types.float, b, types.glsl, val_a[0], val_b[0]),
multiply(types.float, b, types.glsl, val_a[1], val_b[1]),
),
multiply(types.float, b, types.glsl, val_a[2], val_b[2]),
),
4 => add(
types.float,
b,
add(
types.float,
b,
add(
types.float,
b,
multiply(types.float, b, types.glsl, val_a[0], val_b[0]),
multiply(types.float, b, types.glsl, val_a[1], val_b[1]),
),
multiply(types.float, b, types.glsl, val_a[2], val_b[2]),
),
multiply(types.float, b, types.glsl, val_a[3], val_b[3]),
),
2 => {
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
let muly = multiply(types.float, b, types.glsl, val_a[1], val_b[1]);
add(types.float, b, mulx, muly)
},
3 => {
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
let muly = multiply(types.float, b, types.glsl, val_a[1], val_b[1]);
let mulz = multiply(types.float, b, types.glsl, val_a[2], val_b[2]);
let accum = add(types.float, b, mulx, muly);
let accum = add(types.float, b, accum, mulz);
accum
},
4 => {
let mulx = multiply(types.float, b, types.glsl, val_a[0], val_b[0]);
let muly = multiply(types.float, b, types.glsl, val_a[1], val_b[1]);
let mulz = multiply(types.float, b, types.glsl, val_a[2], val_b[2]);
let mulw = multiply(types.float, b, types.glsl, val_a[3], val_b[3]);
let accum = add(types.float, b, mulx, muly);
let accum = add(types.float, b, accum, mulz);
let accum = add(types.float, b, accum, mulw);
accum
},
_ => unreachable!("Invalid opcode size {}", instruction.opcode.size),
};
mapping.insert(instruction.outputs[0], dot);
@@ -1187,45 +1140,31 @@ pub(crate) fn compile_interval_function(
param_one(types.float, b, &mut mapping, instruction, |b, val_a| {
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
let one = b.constant_bit32(types.float, (1.0f32).to_bits());
let ge1 = b.f_sub(types.float, None, val_a.1, val_a.0).unwrap();
let ge1 = b
.f_ord_greater_than_equal(
types.bool,
None,
b.f_sub(types.float, None, val_a.1, val_a.0).unwrap(),
one,
)
.f_ord_greater_than_equal(types.bool, None, ge1, one)
.unwrap();
(
b.select(
types.float,
None,
ge1,
zero,
b.ext_inst(
let fract_low = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Fract as u32,
[IdRef(val_a.0)],
)
.unwrap(),
)
.unwrap(),
b.select(
types.float,
None,
ge1,
one,
b.ext_inst(
.unwrap();
let fract_high = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Fract as u32,
[IdRef(val_a.1)],
)
.unwrap(),
)
.unwrap(),
.unwrap();
(
b.select(types.float, None, ge1, zero, fract_low).unwrap(),
b.select(types.float, None, ge1, one, fract_high).unwrap(),
)
});
},
@@ -1243,22 +1182,24 @@ pub(crate) fn compile_interval_function(
} else {
val_a
};
let lower_cycle = b.f_div(types.float, None, val_a.0, pi).unwrap();
let lower_cycle = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Floor as u32,
[IdRef(b.f_div(types.float, None, val_a.0, pi).unwrap())],
[IdRef(lower_cycle)],
)
.unwrap();
let upper_cycle = b.f_div(types.float, None, val_a.1, pi).unwrap();
let upper_cycle = b
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::Floor as u32,
[IdRef(b.f_div(types.float, None, val_a.1, pi).unwrap())],
[IdRef(upper_cycle)],
)
.unwrap();
let same_cycle = b
@@ -1266,13 +1207,10 @@ pub(crate) fn compile_interval_function(
.unwrap();
let cycle = b.f_mod(types.float, None, upper_cycle, two).unwrap();
let within_one_cycle = b
.f_ord_equal(
types.bool,
None,
b.f_sub(types.float, None, upper_cycle, lower_cycle)
.unwrap(),
one,
)
.f_sub(types.float, None, upper_cycle, lower_cycle)
.unwrap();
let within_one_cycle = b
.f_ord_equal(types.bool, None, within_one_cycle, one)
.unwrap();
let temp0 = b
.ext_inst(
@@ -1292,65 +1230,43 @@ pub(crate) fn compile_interval_function(
[IdRef(val_a.1)],
)
.unwrap();
let lower_valid = b.f_ord_equal(types.bool, None, cycle, zero).unwrap();
let lower_valid = b
.logical_or(
types.bool,
None,
same_cycle,
b.logical_and(
types.bool,
None,
within_one_cycle,
b.f_ord_equal(types.bool, None, cycle, zero).unwrap(),
)
.unwrap(),
)
.logical_and(types.bool, None, within_one_cycle, lower_valid)
.unwrap();
let lower_valid = b
.logical_or(types.bool, None, same_cycle, lower_valid)
.unwrap();
let upper_valid = b.f_ord_equal(types.bool, None, cycle, one).unwrap();
let upper_valid = b
.logical_and(types.bool, None, within_one_cycle, upper_valid)
.unwrap();
let upper_valid = b
.logical_or(
types.bool,
None,
same_cycle,
b.logical_and(
types.bool,
None,
within_one_cycle,
b.f_ord_equal(types.bool, None, cycle, one).unwrap(),
)
.unwrap(),
)
.logical_or(types.bool, None, same_cycle, upper_valid)
.unwrap();
let lower = b
.select(
types.float,
None,
lower_valid,
b.ext_inst(
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::FMin as u32,
[IdRef(temp0), IdRef(temp1)],
)
.unwrap(),
minus_one,
)
.unwrap();
let lower = b
.select(types.float, None, lower_valid, lower, minus_one)
.unwrap();
let upper = b
.select(
types.float,
None,
upper_valid,
b.ext_inst(
.ext_inst(
types.float,
None,
types.glsl,
spirv::GLOp::FMax as u32,
[IdRef(temp0), IdRef(temp1)],
)
.unwrap(),
one,
)
.unwrap();
let upper = b
.select(types.float, None, upper_valid, upper, one)
.unwrap();
(lower, upper)
});
@@ -1378,15 +1294,11 @@ pub(crate) fn compile_interval_function(
[IdRef(val_a.1)],
)
.unwrap();
let result_valid = b
.logical_and(
types.bool,
None,
b.f_ord_less_than(types.bool, None, size, pi).unwrap(),
b.f_ord_greater_than_equal(types.bool, None, upper_tmp, lower_tmp)
.unwrap(),
)
let lt = b.f_ord_less_than(types.bool, None, size, pi).unwrap();
let gte = b
.f_ord_greater_than_equal(types.bool, None, upper_tmp, lower_tmp)
.unwrap();
let result_valid = b.logical_and(types.bool, None, lt, gte).unwrap();
(
b.select(types.float, None, result_valid, lower_tmp, nan)
.unwrap(),
@@ -1418,16 +1330,13 @@ pub(crate) fn compile_interval_function(
[IdRef(val_a.1)],
)
.unwrap();
let result_valid = b
.logical_and(
types.bool,
None,
b.f_ord_greater_than_equal(types.bool, None, val_a.0, minus_one)
.unwrap(),
b.f_ord_less_than_equal(types.bool, None, val_a.1, one)
.unwrap(),
)
let gte = b
.f_ord_greater_than_equal(types.bool, None, val_a.0, minus_one)
.unwrap();
let lte = b
.f_ord_less_than_equal(types.bool, None, val_a.1, one)
.unwrap();
let result_valid = b.logical_and(types.bool, None, gte, lte).unwrap();
(
b.select(types.float, None, result_valid, lower_tmp, nan)
.unwrap(),
@@ -1459,16 +1368,13 @@ pub(crate) fn compile_interval_function(
[IdRef(val_a.1)],
)
.unwrap();
let result_valid = b
.logical_and(
types.bool,
None,
b.f_ord_greater_than_equal(types.bool, None, val_a.0, minus_one)
.unwrap(),
b.f_ord_less_than_equal(types.bool, None, val_a.1, one)
.unwrap(),
)
let gte = b
.f_ord_greater_than_equal(types.bool, None, val_a.0, minus_one)
.unwrap();
let lte = b
.f_ord_less_than_equal(types.bool, None, val_a.1, one)
.unwrap();
let result_valid = b.logical_and(types.bool, None, gte, lte).unwrap();
(
b.select(types.float, None, result_valid, lower_tmp, nan)
.unwrap(),
@@ -1822,12 +1728,9 @@ pub(crate) fn compile_interval_function(
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4 as usize]);
let dot = add(
types.float,
b,
square(types.float, b, types.bool, types.glsl, pos_part[0]),
square(types.float, b, types.bool, types.glsl, pos_part[2]),
);
let squ1 = square(types.float, b, types.bool, types.glsl, pos_part[0]);
let squ2 = square(types.float, b, types.bool, types.glsl, pos_part[2]);
let dot = add(types.float, b, squ1, squ2);
let sqrt = (
b.ext_inst(
types.float,
-31
View File
@@ -106,37 +106,6 @@ pub(crate) fn compile_point_function(
}
}
fn param_four(
float: u32,
b: &mut rspirv::dr::Builder,
mapping: &mut HashMap<u32, u32>,
instruction: &SSAInstruction,
func: impl Fn(&mut rspirv::dr::Builder, u32, u32, u32, u32) -> u32,
) {
for i in 0..instruction.opcode.size as usize {
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
let val_b = input_resolve(
float,
b,
&mapping,
instruction.inputs[i + instruction.opcode.size as usize],
);
let val_c = input_resolve(
float,
b,
&mapping,
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
);
let val_d = input_resolve(
float,
b,
&mapping,
instruction.inputs[i + (instruction.opcode.size as usize * 3)],
);
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c, val_d));
}
}
match instruction.opcode.opcode {
SSAStop => {
let zero = b.constant_bit32(types.float, (0.0f32).to_bits());
+8 -11
View File
@@ -6,10 +6,7 @@ use crate::{
DUMP_SPV_DIS_TO_FILE,
instruction_set::InstructionSet,
spirv_compilers::{
SpirVTypes,
//gradient::compile_gradient_function,
//interval::compile_interval_function,
point::compile_point_function,
SpirVTypes, interval::compile_interval_function, point::compile_point_function,
},
};
@@ -477,7 +474,7 @@ impl SSATape {
let void = b.type_void();
let float = b.type_float(32);
let bool = b.type_bool();
let choice = b.type_int(2, 0);
let choice = b.type_int(8, 0);
let vec2 = b.type_vector(float, 2);
let vec3 = b.type_vector(float, 3);
let vec4 = b.type_vector(float, 4);
@@ -508,12 +505,12 @@ impl SSATape {
if with_module { Some(1000) } else { None },
);
//compile_interval_function(
// &mut b,
// &self,
// types,
// if with_module { Some(2000) } else { None },
//);
compile_interval_function(
&mut b,
&self,
types,
if with_module { Some(2000) } else { None },
);
//compile_gradient_function(
// &mut b,
+1
View File
@@ -248,6 +248,7 @@ impl Grad {
/// Checks that the two values are roughly equal, panicking otherwise
#[cfg(test)]
#[allow(unused)]
pub(crate) fn compare_eq(&self, other: Self) {
let d = (self.v - other.v)
.abs()
+3 -3
View File
@@ -6,10 +6,9 @@ use std::simd::{
use crate::{
interpreters::{
Mask, VALUE_0, VALUE_1, VALUE_2, VALUE_05, VALUE_M1, VALUE_NAN, VALUE_PI, VALUE_PI_2,
VALUE_TAU, Value, glfract, glsign,
Mask, VALUE_0, VALUE_1, VALUE_2, VALUE_M1, VALUE_NAN, VALUE_PI, Value, glfract, glsign,
},
vm::choice::{Choice, VChoice},
vm::choice::VChoice,
};
/// Stores a range, with conservative calculations to guarantee that it always
@@ -469,6 +468,7 @@ impl Interval {
/// Checks that the two values are roughly equal, panicking otherwise
#[cfg(test)]
#[allow(unused)]
pub(crate) fn compare_eq(&self, other: Self) {
let d = (self.lower - other.lower)
.abs()
+1 -6
View File
@@ -1,9 +1,4 @@
use std::simd::{
StdFloat,
cmp::{SimdPartialEq, SimdPartialOrd},
num::SimdFloat,
u32x8,
};
use std::simd::u32x8;
/// A single choice made at a min/max node.
///