fmt clippy
This commit is contained in:
+14
-20
@@ -422,14 +422,13 @@ impl App {
|
|||||||
} else {
|
} else {
|
||||||
DEPTH_FORMAT_ORDERING.iter()
|
DEPTH_FORMAT_ORDERING.iter()
|
||||||
})
|
})
|
||||||
.filter(|format| {
|
.find(|format| {
|
||||||
physical_device
|
physical_device
|
||||||
.format_properties(**format)
|
.format_properties(**format)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.optimal_tiling_features
|
.optimal_tiling_features
|
||||||
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
|
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
|
||||||
})
|
})
|
||||||
.next()
|
|
||||||
.expect("Could not find suitable depth format!");
|
.expect("Could not find suitable depth format!");
|
||||||
|
|
||||||
info!("Using depth format {:?}", depth_format);
|
info!("Using depth format {:?}", depth_format);
|
||||||
@@ -754,7 +753,6 @@ impl ApplicationHandler for App {
|
|||||||
.surface_present_modes(&surface, Default::default())
|
.surface_present_modes(&surface, Default::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
||||||
present_modes
|
present_modes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.min_by_key(|p| {
|
.min_by_key(|p| {
|
||||||
@@ -1073,7 +1071,8 @@ impl ApplicationHandler for App {
|
|||||||
event: DeviceEvent,
|
event: DeviceEvent,
|
||||||
) {
|
) {
|
||||||
if let DeviceEvent::MouseMotion { delta } = &event
|
if let DeviceEvent::MouseMotion { delta } = &event
|
||||||
&& self.cstate.looking {
|
&& self.cstate.looking
|
||||||
|
{
|
||||||
self.cstate.forward.x += delta.1 as f32 * self.gstate.cursor_sensitivity * 0.3;
|
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.y += delta.0 as f32 * self.gstate.cursor_sensitivity * 0.3;
|
||||||
self.cstate.forward.x += 360f32 % 360f32;
|
self.cstate.forward.x += 360f32 % 360f32;
|
||||||
@@ -1090,8 +1089,7 @@ impl ApplicationHandler for App {
|
|||||||
let rcx_clone = self.rcx.clone();
|
let rcx_clone = self.rcx.clone();
|
||||||
let mut rcx_lock = rcx_clone.lock().unwrap();
|
let mut rcx_lock = rcx_clone.lock().unwrap();
|
||||||
let rcx = rcx_lock.as_mut().unwrap();
|
let rcx = rcx_lock.as_mut().unwrap();
|
||||||
if self.draw_gui
|
if self.draw_gui && rcx.gui.update(&event) {
|
||||||
&& rcx.gui.update(&event) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
match &event {
|
match &event {
|
||||||
@@ -1200,32 +1198,28 @@ impl App {
|
|||||||
fn move_camera(&mut self) {
|
fn move_camera(&mut self) {
|
||||||
if self.cstate.looking {
|
if self.cstate.looking {
|
||||||
if self.cstate.keys.w {
|
if self.cstate.keys.w {
|
||||||
self.cstate.position -=
|
self.cstate.position -= Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
||||||
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
|
||||||
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
||||||
* Vec3::Z
|
* Vec3::Z
|
||||||
* 0.01
|
* 0.01
|
||||||
* self.gstate.move_speed;
|
* self.gstate.move_speed;
|
||||||
}
|
}
|
||||||
if self.cstate.keys.s {
|
if self.cstate.keys.s {
|
||||||
self.cstate.position +=
|
self.cstate.position += Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
||||||
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
|
||||||
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
||||||
* Vec3::Z
|
* Vec3::Z
|
||||||
* 0.01
|
* 0.01
|
||||||
* self.gstate.move_speed;
|
* self.gstate.move_speed;
|
||||||
}
|
}
|
||||||
if self.cstate.keys.a {
|
if self.cstate.keys.a {
|
||||||
self.cstate.position -=
|
self.cstate.position -= Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
||||||
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
|
||||||
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
||||||
* Vec3::X
|
* Vec3::X
|
||||||
* 0.01
|
* 0.01
|
||||||
* self.gstate.move_speed;
|
* self.gstate.move_speed;
|
||||||
}
|
}
|
||||||
if self.cstate.keys.d {
|
if self.cstate.keys.d {
|
||||||
self.cstate.position +=
|
self.cstate.position += Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
||||||
Mat3::from_rotation_y(-self.cstate.forward.y.to_radians())
|
|
||||||
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
* Mat3::from_rotation_x(-self.cstate.forward.x.to_radians())
|
||||||
* Vec3::X
|
* Vec3::X
|
||||||
* 0.01
|
* 0.01
|
||||||
@@ -1504,7 +1498,7 @@ impl App {
|
|||||||
fn add_commands_depth_pass(
|
fn add_commands_depth_pass(
|
||||||
&self,
|
&self,
|
||||||
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
||||||
push_constants: &Vec<PushConstantData>,
|
push_constants: &[PushConstantData],
|
||||||
trace_set: Arc<DescriptorSet>,
|
trace_set: Arc<DescriptorSet>,
|
||||||
frame_index: usize,
|
frame_index: usize,
|
||||||
) {
|
) {
|
||||||
@@ -1545,7 +1539,7 @@ impl App {
|
|||||||
fn add_commands_normal_pass(
|
fn add_commands_normal_pass(
|
||||||
&self,
|
&self,
|
||||||
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
||||||
push_constants: &Vec<PushConstantData>,
|
push_constants: &[PushConstantData],
|
||||||
normals_set1: Arc<DescriptorSet>,
|
normals_set1: Arc<DescriptorSet>,
|
||||||
normals_set2: Arc<DescriptorSet>,
|
normals_set2: Arc<DescriptorSet>,
|
||||||
frame_index: usize,
|
frame_index: usize,
|
||||||
@@ -2082,8 +2076,9 @@ impl App {
|
|||||||
match work {
|
match work {
|
||||||
WorkComplete::GetPushConstants(pc, future, index) => {
|
WorkComplete::GetPushConstants(pc, future, index) => {
|
||||||
push_constants[index] = pc;
|
push_constants[index] = pc;
|
||||||
push_constant_future = if push_constant_future.is_some() {
|
push_constant_future =
|
||||||
Some(push_constant_future.unwrap().join(future).boxed())
|
if let Some(push_constant_future) = push_constant_future {
|
||||||
|
Some(push_constant_future.join(future).boxed())
|
||||||
} else {
|
} else {
|
||||||
Some(future.boxed())
|
Some(future.boxed())
|
||||||
};
|
};
|
||||||
@@ -2639,8 +2634,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dump_pipeline_cache(cache: Arc<PipelineCache>) {
|
fn dump_pipeline_cache(cache: Arc<PipelineCache>) {
|
||||||
if PIPELINE_CACHING
|
if PIPELINE_CACHING && let Ok(data) = cache.get_data() {
|
||||||
&& let Ok(data) = cache.get_data() {
|
|
||||||
info!("Dumping pipeline cache...");
|
info!("Dumping pipeline cache...");
|
||||||
let tmp_path = relpath("pipeline_cache.bin.tmp");
|
let tmp_path = relpath("pipeline_cache.bin.tmp");
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ impl Scene {
|
|||||||
compute_queue: &Arc<Queue>,
|
compute_queue: &Arc<Queue>,
|
||||||
memory_allocator: &Arc<dyn MemoryAllocator>,
|
memory_allocator: &Arc<dyn MemoryAllocator>,
|
||||||
command_buffer_allocator: &Arc<dyn CommandBufferAllocator>,
|
command_buffer_allocator: &Arc<dyn CommandBufferAllocator>,
|
||||||
meshes: &Vec<Mesh>,
|
meshes: &[Mesh],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// For simplicity, we build a single command buffer that builds the acceleration
|
// For simplicity, we build a single command buffer that builds the acceleration
|
||||||
// structure, then waits for its execution to complete.
|
// structure, then waits for its execution to complete.
|
||||||
|
|||||||
@@ -117,12 +117,8 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
|
|
||||||
let trace_shader_module =
|
let trace_shader_module =
|
||||||
sdf_specialize_module(device.clone(), &parts, trace_module, "trace");
|
sdf_specialize_module(device.clone(), &parts, trace_module, "trace");
|
||||||
let normals_shader_module = sdf_specialize_module(
|
let normals_shader_module =
|
||||||
device.clone(),
|
sdf_specialize_module(device.clone(), &parts, normals_module, "normals");
|
||||||
&parts,
|
|
||||||
normals_module,
|
|
||||||
"normals",
|
|
||||||
);
|
|
||||||
|
|
||||||
let (trace_pipeline, normals_pipeline) = deferred_pipelines_recompile(
|
let (trace_pipeline, normals_pipeline) = deferred_pipelines_recompile(
|
||||||
device,
|
device,
|
||||||
@@ -268,18 +264,10 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
) => {
|
) => {
|
||||||
let csg_start = Instant::now();
|
let csg_start = Instant::now();
|
||||||
let mut csg = csg.write().unwrap();
|
let mut csg = csg.write().unwrap();
|
||||||
csg.trace_shader_module = sdf_specialize_module(
|
csg.trace_shader_module =
|
||||||
device.clone(),
|
sdf_specialize_module(device.clone(), &csg.parts, trace_module, "trace");
|
||||||
&csg.parts,
|
csg.normals_shader_module =
|
||||||
trace_module,
|
sdf_specialize_module(device.clone(), &csg.parts, normals_module, "normals");
|
||||||
"trace",
|
|
||||||
);
|
|
||||||
csg.normals_shader_module = sdf_specialize_module(
|
|
||||||
device.clone(),
|
|
||||||
&csg.parts,
|
|
||||||
normals_module,
|
|
||||||
"normals",
|
|
||||||
);
|
|
||||||
|
|
||||||
(csg.trace_pipeline, csg.normals_pipeline) = deferred_pipelines_recompile(
|
(csg.trace_pipeline, csg.normals_pipeline) = deferred_pipelines_recompile(
|
||||||
device,
|
device,
|
||||||
|
|||||||
@@ -307,16 +307,14 @@ impl<'csg> IntervalInterpreter<'csg> {
|
|||||||
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);
|
||||||
return ((d2 * (Interval::ONE - h)) + (d1 * h))
|
((d2 * (Interval::ONE - h)) + (d1 * h)) - k * h * (Interval::ONE - 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);
|
||||||
return ((d2 * (Interval::ONE - h)) + (-d1 * h))
|
((d2 * (Interval::ONE - h)) + (-d1 * h)) + k * h * (Interval::ONE - h)
|
||||||
+ k * h * (Interval::ONE - h);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
SSASmoothMinMaterial => todo!(),
|
SSASmoothMinMaterial => todo!(),
|
||||||
@@ -394,6 +392,6 @@ impl<'csg> IntervalInterpreter<'csg> {
|
|||||||
SSAStop => return Interval::ZERO,
|
SSAStop => return Interval::ZERO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Interval::NAN;
|
Interval::NAN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ pub mod point;
|
|||||||
pub type Value = std::simd::f32x8;
|
pub type Value = std::simd::f32x8;
|
||||||
pub type Mask = std::simd::mask32x8;
|
pub type Mask = std::simd::mask32x8;
|
||||||
|
|
||||||
pub const VALUE_NAN: Value = Value::splat(core::f32::NAN);
|
pub const VALUE_NAN: Value = Value::splat(f32::NAN);
|
||||||
pub const VALUE_1: Value = Value::splat(1.0);
|
pub const VALUE_1: Value = Value::splat(1.0);
|
||||||
pub const VALUE_0: Value = Value::splat(0.0);
|
pub const VALUE_0: Value = Value::splat(0.0);
|
||||||
pub const VALUE_05: Value = Value::splat(0.5);
|
pub const VALUE_05: Value = Value::splat(0.5);
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ impl<'csg> PointInterpreter<'csg> {
|
|||||||
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| glfract(val_a));
|
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());
|
||||||
@@ -258,14 +258,14 @@ impl<'csg> PointInterpreter<'csg> {
|
|||||||
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);
|
||||||
return ((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);
|
||||||
return ((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!(),
|
||||||
@@ -354,6 +354,6 @@ impl<'csg> PointInterpreter<'csg> {
|
|||||||
SSAStop => return VALUE_0,
|
SSAStop => return VALUE_0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return VALUE_NAN;
|
VALUE_NAN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32)) -> (u32, u32),
|
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32)) -> (u32, u32),
|
||||||
) {
|
) {
|
||||||
for i in 0..instruction.opcode.size as usize {
|
for i in 0..instruction.opcode.size as usize {
|
||||||
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
|
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
|
||||||
mapping.insert(instruction.outputs[i], func(b, val_a));
|
mapping.insert(instruction.outputs[i], func(b, val_a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,11 +75,11 @@ pub(crate) fn compile_interval_function(
|
|||||||
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32), (u32, u32)) -> (u32, u32),
|
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32), (u32, u32)) -> (u32, u32),
|
||||||
) {
|
) {
|
||||||
for i in 0..instruction.opcode.size as usize {
|
for i in 0..instruction.opcode.size as usize {
|
||||||
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
|
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
|
||||||
let val_b = input_resolve(
|
let val_b = input_resolve(
|
||||||
float,
|
float,
|
||||||
b,
|
b,
|
||||||
&mapping,
|
mapping,
|
||||||
instruction.inputs[i + instruction.opcode.size as usize],
|
instruction.inputs[i + instruction.opcode.size as usize],
|
||||||
);
|
);
|
||||||
mapping.insert(instruction.outputs[i], func(b, val_a, val_b));
|
mapping.insert(instruction.outputs[i], func(b, val_a, val_b));
|
||||||
@@ -94,17 +94,17 @@ pub(crate) fn compile_interval_function(
|
|||||||
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32), (u32, u32), (u32, u32)) -> (u32, u32),
|
func: impl Fn(&mut rspirv::dr::Builder, (u32, u32), (u32, u32), (u32, u32)) -> (u32, u32),
|
||||||
) {
|
) {
|
||||||
for i in 0..instruction.opcode.size as usize {
|
for i in 0..instruction.opcode.size as usize {
|
||||||
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
|
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
|
||||||
let val_b = input_resolve(
|
let val_b = input_resolve(
|
||||||
float,
|
float,
|
||||||
b,
|
b,
|
||||||
&mapping,
|
mapping,
|
||||||
instruction.inputs[i + instruction.opcode.size as usize],
|
instruction.inputs[i + instruction.opcode.size as usize],
|
||||||
);
|
);
|
||||||
let val_c = input_resolve(
|
let val_c = input_resolve(
|
||||||
float,
|
float,
|
||||||
b,
|
b,
|
||||||
&mapping,
|
mapping,
|
||||||
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
|
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
|
||||||
);
|
);
|
||||||
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c));
|
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c));
|
||||||
@@ -299,7 +299,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
bool: u32,
|
bool: u32,
|
||||||
glsl: u32,
|
glsl: u32,
|
||||||
opcode_size: u8,
|
opcode_size: u8,
|
||||||
val_a: &Vec<(u32, u32)>,
|
val_a: &[(u32, u32)],
|
||||||
) -> (u32, u32) {
|
) -> (u32, u32) {
|
||||||
let zero_const = b.constant_bit32(float, (0.0f32).to_bits());
|
let zero_const = b.constant_bit32(float, (0.0f32).to_bits());
|
||||||
let val_a_lowers = val_a
|
let val_a_lowers = val_a
|
||||||
@@ -1001,8 +1001,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
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);
|
||||||
let accum = add(types.float, b, accum, mulz);
|
add(types.float, b, accum, mulz)
|
||||||
accum
|
|
||||||
},
|
},
|
||||||
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]);
|
||||||
@@ -1011,8 +1010,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
let mulw = multiply(types.float, b, types.glsl, val_a[3], val_b[3]);
|
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, mulx, muly);
|
||||||
let accum = add(types.float, b, accum, mulz);
|
let accum = add(types.float, b, accum, mulz);
|
||||||
let accum = add(types.float, b, accum, mulw);
|
add(types.float, b, accum, mulw)
|
||||||
accum
|
|
||||||
},
|
},
|
||||||
_ => unreachable!("Invalid opcode size {}", instruction.opcode.size),
|
_ => unreachable!("Invalid opcode size {}", instruction.opcode.size),
|
||||||
};
|
};
|
||||||
@@ -1625,8 +1623,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let radius =
|
let radius = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
|
||||||
input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
|
|
||||||
|
|
||||||
let length = length(types.float, b, types.bool, types.glsl, 3, &pos_part);
|
let length = length(types.float, b, types.bool, types.glsl, 3, &pos_part);
|
||||||
let sphere = sub(types.float, b, length, radius);
|
let sphere = sub(types.float, b, length, radius);
|
||||||
@@ -1690,7 +1687,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
types.bool,
|
types.bool,
|
||||||
types.glsl,
|
types.glsl,
|
||||||
3,
|
3,
|
||||||
&vec![qx_limit, qy_limit, qz_limit],
|
&[qx_limit, qy_limit, qz_limit],
|
||||||
);
|
);
|
||||||
|
|
||||||
let max1 =
|
let max1 =
|
||||||
@@ -1725,8 +1722,8 @@ pub(crate) fn compile_interval_function(
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
|
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
|
||||||
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4 as usize]);
|
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4_usize]);
|
||||||
|
|
||||||
let squ1 = square(types.float, b, types.bool, types.glsl, pos_part[0]);
|
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 squ2 = square(types.float, b, types.bool, types.glsl, pos_part[2]);
|
||||||
@@ -1757,7 +1754,7 @@ pub(crate) fn compile_interval_function(
|
|||||||
types.bool,
|
types.bool,
|
||||||
types.glsl,
|
types.glsl,
|
||||||
2,
|
2,
|
||||||
&vec![subtx, pos_part[1]],
|
&[subtx, pos_part[1]],
|
||||||
);
|
);
|
||||||
|
|
||||||
mapping.insert(instruction.outputs[0], sub(types.float, b, length, rad2));
|
mapping.insert(instruction.outputs[0], sub(types.float, b, length, rad2));
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ pub(crate) fn compile_point_function(
|
|||||||
func: impl Fn(&mut rspirv::dr::Builder, u32) -> u32,
|
func: impl Fn(&mut rspirv::dr::Builder, u32) -> u32,
|
||||||
) {
|
) {
|
||||||
for i in 0..instruction.opcode.size as usize {
|
for i in 0..instruction.opcode.size as usize {
|
||||||
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
|
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
|
||||||
mapping.insert(instruction.outputs[i], func(b, val_a));
|
mapping.insert(instruction.outputs[i], func(b, val_a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,11 +70,11 @@ pub(crate) fn compile_point_function(
|
|||||||
func: impl Fn(&mut rspirv::dr::Builder, u32, u32) -> u32,
|
func: impl Fn(&mut rspirv::dr::Builder, u32, u32) -> u32,
|
||||||
) {
|
) {
|
||||||
for i in 0..instruction.opcode.size as usize {
|
for i in 0..instruction.opcode.size as usize {
|
||||||
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
|
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
|
||||||
let val_b = input_resolve(
|
let val_b = input_resolve(
|
||||||
float,
|
float,
|
||||||
b,
|
b,
|
||||||
&mapping,
|
mapping,
|
||||||
instruction.inputs[i + instruction.opcode.size as usize],
|
instruction.inputs[i + instruction.opcode.size as usize],
|
||||||
);
|
);
|
||||||
mapping.insert(instruction.outputs[i], func(b, val_a, val_b));
|
mapping.insert(instruction.outputs[i], func(b, val_a, val_b));
|
||||||
@@ -89,17 +89,17 @@ pub(crate) fn compile_point_function(
|
|||||||
func: impl Fn(&mut rspirv::dr::Builder, u32, u32, u32) -> u32,
|
func: impl Fn(&mut rspirv::dr::Builder, u32, u32, u32) -> u32,
|
||||||
) {
|
) {
|
||||||
for i in 0..instruction.opcode.size as usize {
|
for i in 0..instruction.opcode.size as usize {
|
||||||
let val_a = input_resolve(float, b, &mapping, instruction.inputs[i]);
|
let val_a = input_resolve(float, b, mapping, instruction.inputs[i]);
|
||||||
let val_b = input_resolve(
|
let val_b = input_resolve(
|
||||||
float,
|
float,
|
||||||
b,
|
b,
|
||||||
&mapping,
|
mapping,
|
||||||
instruction.inputs[i + instruction.opcode.size as usize],
|
instruction.inputs[i + instruction.opcode.size as usize],
|
||||||
);
|
);
|
||||||
let val_c = input_resolve(
|
let val_c = input_resolve(
|
||||||
float,
|
float,
|
||||||
b,
|
b,
|
||||||
&mapping,
|
mapping,
|
||||||
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
|
instruction.inputs[i + (instruction.opcode.size as usize * 2)],
|
||||||
);
|
);
|
||||||
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c));
|
mapping.insert(instruction.outputs[i], func(b, val_a, val_b, val_c));
|
||||||
@@ -629,8 +629,7 @@ pub(crate) fn compile_point_function(
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let pos = b.composite_construct(types.vec3, None, pos_part).unwrap();
|
let pos = b.composite_construct(types.vec3, None, pos_part).unwrap();
|
||||||
let radius =
|
let radius = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
|
||||||
input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
|
|
||||||
|
|
||||||
let length = b
|
let length = b
|
||||||
.ext_inst(
|
.ext_inst(
|
||||||
@@ -745,8 +744,8 @@ pub(crate) fn compile_point_function(
|
|||||||
.composite_construct(types.vec2, None, [pos_part[0], pos_part[2]])
|
.composite_construct(types.vec2, None, [pos_part[0], pos_part[2]])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3 as usize]);
|
let rad1 = input_resolve(types.float, b, &mapping, instruction.inputs[3_usize]);
|
||||||
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4 as usize]);
|
let rad2 = input_resolve(types.float, b, &mapping, instruction.inputs[4_usize]);
|
||||||
|
|
||||||
let dot = b.dot(types.float, None, pos_vec2, pos_vec2).unwrap();
|
let dot = b.dot(types.float, None, pos_vec2, pos_vec2).unwrap();
|
||||||
let sqrt = b
|
let sqrt = b
|
||||||
@@ -798,10 +797,8 @@ pub(crate) fn compile_point_function(
|
|||||||
let select_less = b.select(types.float, None, less, onen, nan).unwrap();
|
let select_less = b.select(types.float, None, less, onen, nan).unwrap();
|
||||||
let select_more =
|
let select_more =
|
||||||
b.select(types.float, None, more, one, select_less).unwrap();
|
b.select(types.float, None, more, one, select_less).unwrap();
|
||||||
let select_eq = b
|
b.select(types.float, None, equal, zero, select_more)
|
||||||
.select(types.float, None, equal, zero, select_more)
|
.unwrap()
|
||||||
.unwrap();
|
|
||||||
select_eq
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ impl SSAOpcodeSized {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn to_raw_opcode(&self) -> GPUOpcode {
|
const fn to_raw_opcode(self) -> GPUOpcode {
|
||||||
use InstructionSet::*;
|
use InstructionSet::*;
|
||||||
use SSAOpcode::*;
|
use SSAOpcode::*;
|
||||||
const fn opcode_drop(inst: InstructionSet, width: u8) -> GPUOpcode {
|
const fn opcode_drop(inst: InstructionSet, width: u8) -> GPUOpcode {
|
||||||
@@ -258,7 +258,7 @@ impl SSATape {
|
|||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
});
|
});
|
||||||
return outputs_register;
|
outputs_register
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compile_to_gpu(&self) -> GPUTape {
|
pub fn compile_to_gpu(&self) -> GPUTape {
|
||||||
@@ -500,21 +500,21 @@ impl SSATape {
|
|||||||
|
|
||||||
compile_point_function(
|
compile_point_function(
|
||||||
&mut b,
|
&mut b,
|
||||||
&self,
|
self,
|
||||||
types,
|
types,
|
||||||
if with_module { Some(1000) } else { None },
|
if with_module { Some(1000) } else { None },
|
||||||
);
|
);
|
||||||
|
|
||||||
compile_interval_function(
|
compile_interval_function(
|
||||||
&mut b,
|
&mut b,
|
||||||
&self,
|
self,
|
||||||
types,
|
types,
|
||||||
if with_module { Some(2000) } else { None },
|
if with_module { Some(2000) } else { None },
|
||||||
);
|
);
|
||||||
|
|
||||||
//compile_gradient_function(
|
//compile_gradient_function(
|
||||||
// &mut b,
|
// &mut b,
|
||||||
// &self,
|
// self,
|
||||||
// types,
|
// types,
|
||||||
// if with_module { Some(3000) } else { None },
|
// if with_module { Some(3000) } else { None },
|
||||||
//);
|
//);
|
||||||
@@ -526,8 +526,7 @@ impl SSATape {
|
|||||||
format!(
|
format!(
|
||||||
"{}.spv-dis",
|
"{}.spv-dis",
|
||||||
humantime::format_rfc3339(std::time::SystemTime::now())
|
humantime::format_rfc3339(std::time::SystemTime::now())
|
||||||
)
|
),
|
||||||
.to_string(),
|
|
||||||
module.disassemble(),
|
module.disassemble(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ impl std::fmt::Debug for Interval {
|
|||||||
impl Interval {
|
impl Interval {
|
||||||
pub const HALF: Self = Self::const_splat(0.5);
|
pub const HALF: Self = Self::const_splat(0.5);
|
||||||
pub const MONE: Self = Self::const_splat(-1.0);
|
pub const MONE: Self = Self::const_splat(-1.0);
|
||||||
pub const NAN: Self = Self::const_splat(core::f32::NAN);
|
pub const NAN: Self = Self::const_splat(f32::NAN);
|
||||||
pub const ONE: Self = Self::const_splat(1.0);
|
pub const ONE: Self = Self::const_splat(1.0);
|
||||||
pub const PI: Self = Self::const_splat(core::f32::consts::PI);
|
pub const PI: Self = Self::const_splat(core::f32::consts::PI);
|
||||||
pub const PI_2: Self = Self::const_splat(core::f32::consts::FRAC_PI_2);
|
pub const PI_2: Self = Self::const_splat(core::f32::consts::FRAC_PI_2);
|
||||||
|
|||||||
@@ -86,6 +86,6 @@ impl std::ops::Not for VChoice {
|
|||||||
|
|
||||||
impl std::ops::BitAndAssign<VChoice> for VChoice {
|
impl std::ops::BitAndAssign<VChoice> for VChoice {
|
||||||
fn bitand_assign(&mut self, other: Self) {
|
fn bitand_assign(&mut self, other: Self) {
|
||||||
self.0 = (self.0) | ((!other.0) & u32x8::splat(3))
|
self.0 |= (!other.0) & u32x8::splat(3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user