clippy
This commit is contained in:
+2
-2
@@ -723,7 +723,7 @@ impl<'csg> Interpreter<'csg> {
|
||||
}
|
||||
}
|
||||
|
||||
fn clear_stacks(&mut self) -> () {
|
||||
fn clear_stacks(&mut self) {
|
||||
self.float_stack.clear();
|
||||
self.vec2_stack.clear();
|
||||
self.vec3_stack.clear();
|
||||
@@ -1704,6 +1704,6 @@ impl<'csg> Interpreter<'csg> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return self.pull(Inputs::Variable);
|
||||
self.pull(Inputs::Variable)
|
||||
}
|
||||
}
|
||||
|
||||
+33
-33
@@ -1,8 +1,8 @@
|
||||
#![feature(variant_count)]
|
||||
use bytemuck::{Zeroable, Pod};
|
||||
use cgmath::{
|
||||
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, Rad, SquareMatrix, Vector2,
|
||||
Vector3, Vector4, Zero,
|
||||
Deg, EuclideanSpace, Euler, Matrix3, Matrix4, Point3, Rad, SquareMatrix,
|
||||
Vector3,
|
||||
};
|
||||
use instruction_set::InputTypes;
|
||||
use vulkano::command_buffer::{CopyBufferInfo, PrimaryCommandBufferAbstract};
|
||||
@@ -15,7 +15,7 @@ use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
||||
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
||||
use vulkano::device::{DeviceOwned, Features, QueueFlags, Queue};
|
||||
use vulkano::format::Format;
|
||||
use vulkano::half::f16;
|
||||
|
||||
use vulkano::image::view::ImageViewCreateInfo;
|
||||
use vulkano::image::{AttachmentImage, SampleCount};
|
||||
use vulkano::memory::allocator::{MemoryAllocatePreference, MemoryUsage, StandardMemoryAllocator};
|
||||
@@ -132,7 +132,7 @@ fn main() {
|
||||
p.queue_family_properties()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.position(|(i, q)| {
|
||||
.position(|(_i, q)| {
|
||||
q.queue_flags.intersects(QueueFlags::TRANSFER)
|
||||
})}
|
||||
|
||||
@@ -563,7 +563,7 @@ fn main() {
|
||||
button: b,
|
||||
..
|
||||
} => {
|
||||
println!("MOUSE {:?}, {:?}, {:?}", d, s, b);
|
||||
println!("MOUSE {d:?}, {s:?}, {b:?}");
|
||||
if b == &MouseButton::Right {
|
||||
looking = s == &ElementState::Pressed;
|
||||
}
|
||||
@@ -595,8 +595,8 @@ fn main() {
|
||||
if looking {
|
||||
camforward.x -= Deg(delta.1 as f32) * gstate.cursor_sensitivity * 0.3;
|
||||
camforward.y += Deg(delta.0 as f32) * gstate.cursor_sensitivity * 0.3;
|
||||
camforward.x = camforward.x + Deg(360f32) % Deg(360f32);
|
||||
camforward.y = camforward.y + Deg(360f32) % Deg(360f32);
|
||||
camforward.x += Deg(360f32) % Deg(360f32);
|
||||
camforward.y += Deg(360f32) % Deg(360f32);
|
||||
}
|
||||
}
|
||||
Event::RedrawEventsCleared => {
|
||||
@@ -721,7 +721,7 @@ fn main() {
|
||||
*sub.write().unwrap() = uniform_data;
|
||||
|
||||
if looking {
|
||||
println!("campos: {:?} camforward: {:?}", campos, camforward);
|
||||
println!("campos: {campos:?} camforward: {camforward:?}");
|
||||
}
|
||||
|
||||
(pc, sub)
|
||||
@@ -767,8 +767,8 @@ fn main() {
|
||||
&descriptor_set_allocator,
|
||||
implicit_layout.clone(),
|
||||
[
|
||||
WriteDescriptorSet::buffer(0, uniform_buffer_subbuffer.clone()),
|
||||
WriteDescriptorSet::buffer(1, cam_set.clone()),
|
||||
WriteDescriptorSet::buffer(0, uniform_buffer_subbuffer),
|
||||
WriteDescriptorSet::buffer(1, cam_set),
|
||||
WriteDescriptorSet::buffer(2, subbuffers.desc.clone()),
|
||||
WriteDescriptorSet::buffer(3, subbuffers.scene.clone()),
|
||||
WriteDescriptorSet::buffer(4, subbuffers.floats.clone()),
|
||||
@@ -790,10 +790,10 @@ fn main() {
|
||||
if COMPUTE_FUZZING {
|
||||
|
||||
let mut fake_csg = vec![];
|
||||
for i in 0..(32)
|
||||
for i in 0..32
|
||||
{
|
||||
fake_csg.push(
|
||||
CSG{ name: format!("fuzz_{}",i), parts: vec![
|
||||
CSG{ name: format!("fuzz_{i}"), parts: vec![
|
||||
CSGPart::opcode(InstructionSet::OPMulVec3Float, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
||||
CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||
CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.7, (i as f64), -0.7].into())]),
|
||||
@@ -835,7 +835,7 @@ fn main() {
|
||||
//WriteDescriptorSet::buffer(9, compute_subbuffers.mat3s.clone()),
|
||||
//WriteDescriptorSet::buffer(10, compute_subbuffers.mat4s.clone()),
|
||||
//WriteDescriptorSet::buffer(11, compute_subbuffers.mats.clone()),
|
||||
WriteDescriptorSet::buffer(12, compute_subbuffers.deps.clone()),
|
||||
WriteDescriptorSet::buffer(12, compute_subbuffers.deps),
|
||||
//WriteDescriptorSet::buffer(20, compute_subbuffers.masks.clone()),
|
||||
WriteDescriptorSet::buffer(30, compute_result_buffer.clone()),],
|
||||
)
|
||||
@@ -871,7 +871,7 @@ fn main() {
|
||||
|
||||
let content = compute_result_buffer.read().unwrap();
|
||||
for (val,csg) in content.iter().zip(fake_csg.iter()) {
|
||||
println!("{:?}",val);
|
||||
println!("{val:?}");
|
||||
let expected = Interpreter::new(csg).scene(Vector3::new(1.,1.,1.)) as f32;
|
||||
if expected != val.f[0] {
|
||||
println!("ERROR: expected {}, got {}", expected, val.f[0]);
|
||||
@@ -886,7 +886,7 @@ fn main() {
|
||||
recreate_swapchain = true;
|
||||
return;
|
||||
}
|
||||
Err(e) => panic!("Failed to acquire next image: {:?}", e),
|
||||
Err(e) => panic!("Failed to acquire next image: {e:?}"),
|
||||
};
|
||||
|
||||
if suboptimal {
|
||||
@@ -1002,7 +1002,7 @@ fn main() {
|
||||
previous_frame_end = Some(sync::now(device.clone()).boxed());
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Failed to flush future: {:?}", e);
|
||||
println!("Failed to flush future: {e:?}");
|
||||
previous_frame_end = Some(sync::now(device.clone()).boxed());
|
||||
}
|
||||
}
|
||||
@@ -1127,9 +1127,9 @@ where
|
||||
depth_range: 0.0..1.0,
|
||||
},
|
||||
]))
|
||||
.fragment_shader(implicit_fs.entry_point("main").unwrap(), implicit_fs_specs.clone())
|
||||
.task_shader(implicit_ts.entry_point("main").unwrap(), implicit_ts_specs.clone())
|
||||
.mesh_shader(implicit_ms.entry_point("main").unwrap(), implicit_ms_specs.clone())
|
||||
.fragment_shader(implicit_fs.entry_point("main").unwrap(), implicit_fs_specs)
|
||||
.task_shader(implicit_ts.entry_point("main").unwrap(), implicit_ts_specs)
|
||||
.mesh_shader(implicit_ms.entry_point("main").unwrap(), implicit_ms_specs)
|
||||
.depth_stencil_state(DepthStencilState::simple_depth_test())
|
||||
.rasterization_state(RasterizationState {
|
||||
//front_face: Fixed(Clockwise),
|
||||
@@ -1137,7 +1137,7 @@ where
|
||||
..RasterizationState::default()
|
||||
})
|
||||
.multisample_state(MultisampleState {
|
||||
rasterization_samples: Subpass::from(render_pass.clone(), 0)
|
||||
rasterization_samples: Subpass::from(render_pass, 0)
|
||||
.unwrap()
|
||||
.num_samples()
|
||||
.unwrap(),
|
||||
@@ -1227,7 +1227,7 @@ where
|
||||
).unwrap();
|
||||
let commands = builder.build().unwrap();
|
||||
|
||||
commands.execute(transfer_queue.clone())
|
||||
commands.execute(transfer_queue)
|
||||
.unwrap()
|
||||
.then_signal_fence_and_flush()
|
||||
.unwrap()
|
||||
@@ -1264,7 +1264,7 @@ fn object_size_dependent_setup(
|
||||
let mut mat2s: Vec<[[f32; 2]; 2]> = vec![Default::default()];
|
||||
let mut mat3s: Vec<[[f32; 3]; 3]> = vec![Default::default()];
|
||||
let mut mat4s: Vec<[[f32; 4]; 4]> = vec![Default::default()];
|
||||
let mut mats: Vec<[[f32; 4]; 4]> = vec![Default::default()];
|
||||
let mats: Vec<[[f32; 4]; 4]> = vec![Default::default()];
|
||||
let mut scene: Vec<[u32; 4]> = vec![Default::default()];
|
||||
let mut deps: Vec<[u8; 2]> = vec![Default::default()];
|
||||
let mut desc: Vec<Description> = vec![Default::default()];
|
||||
@@ -1496,16 +1496,16 @@ fn object_size_dependent_setup(
|
||||
|
||||
}
|
||||
|
||||
println!("floats: {:?}", floats);
|
||||
println!("vec2s: {:?}", vec2s);
|
||||
println!("vec3/4s: {:?}", vec4s);
|
||||
println!("mat2s: {:?}", mat2s);
|
||||
println!("mat3s: {:?}", mat3s);
|
||||
println!("mat4s: {:?}", mat4s);
|
||||
println!("mats: {:?}", mats);
|
||||
println!("scene: {:?}", scene);
|
||||
println!("deps: {:?}", deps);
|
||||
println!("desc: {:?}", desc);
|
||||
println!("floats: {floats:?}");
|
||||
println!("vec2s: {vec2s:?}");
|
||||
println!("vec3/4s: {vec4s:?}");
|
||||
println!("mat2s: {mat2s:?}");
|
||||
println!("mat3s: {mat3s:?}");
|
||||
println!("mat4s: {mat4s:?}");
|
||||
println!("mats: {mats:?}");
|
||||
println!("scene: {scene:?}");
|
||||
println!("deps: {deps:?}");
|
||||
println!("desc: {desc:?}");
|
||||
|
||||
let fragment_masks_buffer = Buffer::new_slice(
|
||||
&allocator,
|
||||
@@ -1538,7 +1538,7 @@ fn object_size_dependent_setup(
|
||||
let csg_mat3s = gpu_buffer(mat3s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_mat4s = gpu_buffer(mat4s, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_mats = gpu_buffer(mats, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_deps = gpu_buffer(deps, &allocator, &staging, command_allocator, queue.clone());
|
||||
let csg_deps = gpu_buffer(deps, &allocator, &staging, command_allocator, queue);
|
||||
|
||||
Subbuffers {
|
||||
masks: fragment_masks_buffer,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fmt::Display;
|
||||
use std::io::{BufReader, Cursor, Read};
|
||||
use std::ops::{AddAssign, MulAssign, Neg};
|
||||
use std::io::{BufReader, Read};
|
||||
|
||||
use std::str::Chars;
|
||||
|
||||
use serde::de::{
|
||||
@@ -8,7 +8,7 @@ use serde::de::{
|
||||
Visitor,
|
||||
};
|
||||
use serde::{forward_to_deserialize_any, Deserialize};
|
||||
use utf8::{BufReadDecoder, BufReadDecoderError};
|
||||
use utf8::{BufReadDecoder};
|
||||
|
||||
type Result<T> = core::result::Result<T, Error>;
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::Message(msg) | Error::UTF8(msg) => f.write_str(msg),
|
||||
_ => f.write_fmt(format_args!("Error: {:?}", self)),
|
||||
_ => f.write_fmt(format_args!("Error: {self:?}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ impl<'de> Deserializer<'de> {
|
||||
Ok(s) => {
|
||||
s.clone_into(&mut self.read_buf);
|
||||
}
|
||||
Err(e) => return Err(Error::UTF8(format!("{}", e))),
|
||||
Err(e) => return Err(Error::UTF8(format!("{e}"))),
|
||||
};
|
||||
}
|
||||
None => return Err(Error::Eof),
|
||||
@@ -175,7 +175,7 @@ impl<'de> Deserializer<'de> {
|
||||
Ok(s) => {
|
||||
s.clone_into(&mut self.read_buf);
|
||||
}
|
||||
Err(e) => return Err(Error::UTF8(format!("{}", e))),
|
||||
Err(e) => return Err(Error::UTF8(format!("{e}"))),
|
||||
};
|
||||
}
|
||||
None => return Err(Error::Eof),
|
||||
|
||||
+21
-28
@@ -1,20 +1,18 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
default,
|
||||
io::{Cursor, Read},
|
||||
mem,
|
||||
};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use cgmath::{
|
||||
num_traits::float, Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, SquareMatrix,
|
||||
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, SquareMatrix,
|
||||
Vector2, Vector3, Vector4,
|
||||
};
|
||||
use obj::{LoadConfig, ObjData, ObjError};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferAllocateInfo, BufferUsage, Subbuffer},
|
||||
half::f16,
|
||||
pipeline::graphics::vertex_input::Vertex,
|
||||
};
|
||||
|
||||
@@ -203,7 +201,7 @@ type MCSGCSGPart = HashMap<String, String>;
|
||||
|
||||
fn matrix3_from_string(input: &String) -> Result<Matrix3<f32>, String> {
|
||||
let vec = input
|
||||
.split(" ")
|
||||
.split(' ')
|
||||
.map(|s| s.parse::<f32>())
|
||||
.collect::<Result<Vec<f32>, _>>()
|
||||
.map_err(|_| "not floats")?;
|
||||
@@ -214,7 +212,7 @@ fn matrix3_from_string(input: &String) -> Result<Matrix3<f32>, String> {
|
||||
|
||||
fn vector3_from_string(input: &String) -> Result<Vector3<f32>, String> {
|
||||
let vec = input
|
||||
.split(" ")
|
||||
.split(' ')
|
||||
.map(|s| s.parse::<f32>())
|
||||
.collect::<Result<Vec<f32>, _>>()
|
||||
.map_err(|_| "not floats")?;
|
||||
@@ -225,7 +223,7 @@ fn vector3_from_string(input: &String) -> Result<Vector3<f32>, String> {
|
||||
|
||||
fn point3_from_string(input: &String) -> Result<Point3<f32>, String> {
|
||||
let vec = input
|
||||
.split(" ")
|
||||
.split(' ')
|
||||
.map(|s| s.parse::<f32>())
|
||||
.collect::<Result<Vec<f32>, _>>()
|
||||
.map_err(|_| "not floats")?;
|
||||
@@ -244,20 +242,17 @@ fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
|
||||
translation: o
|
||||
.get("t")
|
||||
.map(point3_from_string)
|
||||
.transpose()
|
||||
.map_err(|e| e.to_string())?
|
||||
.transpose()?
|
||||
.unwrap_or(Point3::origin()),
|
||||
rotation: o
|
||||
.get("r")
|
||||
.map(matrix3_from_string)
|
||||
.transpose()
|
||||
.map_err(|e| e.to_string())?
|
||||
.transpose()?
|
||||
.unwrap_or(Matrix3::identity()),
|
||||
scale: o
|
||||
.get("s")
|
||||
.map(vector3_from_string)
|
||||
.transpose()
|
||||
.map_err(|e| e.to_string())?
|
||||
.transpose()?
|
||||
.unwrap_or(Vector3 {
|
||||
x: 1.,
|
||||
y: 1.,
|
||||
@@ -268,8 +263,7 @@ fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
|
||||
fn get_color(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
|
||||
Ok(o.get("color")
|
||||
.map(vector3_from_string)
|
||||
.transpose()
|
||||
.map_err(|e| e.to_string())?
|
||||
.transpose()?
|
||||
.unwrap_or(Vector3 {
|
||||
x: 255.,
|
||||
y: 255.,
|
||||
@@ -280,8 +274,7 @@ fn get_color(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
|
||||
fn get_rgb(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
|
||||
Ok(o.get("rgb")
|
||||
.map(vector3_from_string)
|
||||
.transpose()
|
||||
.map_err(|e| e.to_string())?
|
||||
.transpose()?
|
||||
.unwrap_or(Vector3 {
|
||||
x: 255.,
|
||||
y: 255.,
|
||||
@@ -293,7 +286,7 @@ fn get_f32(o: &HashMap<String, String>, tag: &str) -> Result<f32, String> {
|
||||
get_f32_default(o, tag, 0.)
|
||||
}
|
||||
|
||||
fn get_f32_default(o: &HashMap<String, String>, tag: &str, default: f32) -> Result<f32, String> {
|
||||
fn get_f32_default(o: &HashMap<String, String>, tag: &str, _default: f32) -> Result<f32, String> {
|
||||
Ok(o.get(tag)
|
||||
.map(|c| c.parse::<f32>())
|
||||
.transpose()
|
||||
@@ -339,7 +332,7 @@ fn get_half(o: &HashMap<String, String>) -> Result<Half, String> {
|
||||
}
|
||||
|
||||
pub fn load_csg(
|
||||
memory_allocator: &MemoryAllocator,
|
||||
_memory_allocator: &MemoryAllocator,
|
||||
input: &mut dyn Read,
|
||||
name: String,
|
||||
) -> Result<Vec<CSG>, String> {
|
||||
@@ -349,10 +342,10 @@ pub fn load_csg(
|
||||
mcsg.object
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, o)| {
|
||||
.map(|(_i, o)| {
|
||||
let name = name.clone() + "_" + o.get("name").unwrap_or(&"unknown".to_owned());
|
||||
let trs = get_trs(&o)?;
|
||||
let color = get_color(&o)?;
|
||||
let _trs = get_trs(o)?;
|
||||
let _color = get_color(o)?;
|
||||
|
||||
let cid = o
|
||||
.get("cid")
|
||||
@@ -371,15 +364,15 @@ pub fn load_csg(
|
||||
.iter()
|
||||
.map(|inpart| {
|
||||
let ty = inpart.get("type").ok_or("no type!")?.as_str();
|
||||
let mut csgpart = CSGPart::opcode(InstructionSet::OPNop, vec![]);
|
||||
let csgpart = CSGPart::opcode(InstructionSet::OPNop, vec![]);
|
||||
match ty {
|
||||
"sphere" => {
|
||||
let blend = get_f32(&inpart, "blend")?;
|
||||
let shell = get_percentage(&inpart, "shell%")?;
|
||||
let power = get_f32_default(&inpart, "power", 2.)?;
|
||||
let rgb = get_rgb(&inpart)?;
|
||||
let trs = get_trs(&inpart)?;
|
||||
let half = get_half(&inpart)?;
|
||||
let _blend = get_f32(inpart, "blend")?;
|
||||
let _shell = get_percentage(inpart, "shell%")?;
|
||||
let _power = get_f32_default(inpart, "power", 2.)?;
|
||||
let _rgb = get_rgb(inpart)?;
|
||||
let _trs = get_trs(inpart)?;
|
||||
let _half = get_half(inpart)?;
|
||||
}
|
||||
_ => {} //return Err("unknown type of csg".to_owned()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user