--wip-- [skip ci]

This commit is contained in:
2025-01-01 20:40:20 +00:00
parent 94f8e0502a
commit b6b252c69d
7 changed files with 1129 additions and 1019 deletions
Generated
+22 -99
View File
@@ -76,15 +76,6 @@ version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
[[package]]
name = "approx"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278"
dependencies = [
"num-traits",
]
[[package]]
name = "arbitrary"
version = "1.4.1"
@@ -327,16 +318,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "cgmath"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a98d30140e3296250832bbaaff83b27dcd6fa3cc70fb6f1f3e5c9c0023b5317"
dependencies = [
"approx",
"num-traits",
]
[[package]]
name = "clipboard-win"
version = "5.4.0"
@@ -574,8 +555,8 @@ dependencies = [
"egui",
"egui-winit",
"image",
"vulkano 0.34.0 (git+https://github.com/vulkano-rs/vulkano.git)",
"vulkano-shaders 0.34.0 (git+https://github.com/vulkano-rs/vulkano.git)",
"vulkano",
"vulkano-shaders",
"winit",
]
@@ -639,17 +620,18 @@ name = "erroccfisuvsc"
version = "0.1.0"
dependencies = [
"bytemuck",
"cgmath",
"egui",
"egui_winit_vulkano",
"foldhash",
"glam",
"obj",
"rand",
"rayon",
"serde",
"serde_json",
"utf-8",
"vulkano 0.34.0 (git+https://github.com/Molive-0/vulkano)",
"vulkano-shaders 0.34.0 (git+https://github.com/Molive-0/vulkano)",
"vulkano",
"vulkano-shaders",
"vulkano-util",
"winit",
]
@@ -767,6 +749,12 @@ dependencies = [
"weezl",
]
[[package]]
name = "glam"
version = "0.29.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677"
[[package]]
name = "half"
version = "2.4.1"
@@ -2339,50 +2327,10 @@ dependencies = [
"xml-rs",
]
[[package]]
name = "vk-parse"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11be98ea9c3e6a91789a99d111087588d597a1e30ecc33fd4c7b8cfdf5161989"
dependencies = [
"xml-rs",
]
[[package]]
name = "vulkano"
version = "0.34.0"
source = "git+https://github.com/Molive-0/vulkano#9bb8ebd8b0c05c23eb83f92435c54ed130cfba97"
dependencies = [
"ash",
"bytemuck",
"crossbeam-queue",
"foldhash",
"half",
"heck 0.5.0",
"indexmap",
"libloading",
"nom",
"once_cell",
"parking_lot",
"proc-macro2",
"quote",
"raw-window-handle",
"raw-window-metal",
"serde",
"serde_json",
"slabbin",
"smallvec",
"thread_local",
"vk-parse 0.16.0",
"vulkano-macros 0.34.0 (git+https://github.com/Molive-0/vulkano)",
"x11-dl",
"x11rb",
]
[[package]]
name = "vulkano"
version = "0.34.0"
source = "git+https://github.com/vulkano-rs/vulkano.git#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
dependencies = [
"ash",
"bytemuck",
@@ -2404,8 +2352,8 @@ dependencies = [
"slabbin",
"smallvec",
"thread_local",
"vk-parse 0.15.0",
"vulkano-macros 0.34.0 (git+https://github.com/vulkano-rs/vulkano.git)",
"vk-parse",
"vulkano-macros",
"x11-dl",
"x11rb",
]
@@ -2413,18 +2361,7 @@ dependencies = [
[[package]]
name = "vulkano-macros"
version = "0.34.0"
source = "git+https://github.com/Molive-0/vulkano#9bb8ebd8b0c05c23eb83f92435c54ed130cfba97"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "vulkano-macros"
version = "0.34.0"
source = "git+https://github.com/vulkano-rs/vulkano.git#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -2435,21 +2372,7 @@ dependencies = [
[[package]]
name = "vulkano-shaders"
version = "0.34.0"
source = "git+https://github.com/Molive-0/vulkano#9bb8ebd8b0c05c23eb83f92435c54ed130cfba97"
dependencies = [
"foldhash",
"heck 0.5.0",
"proc-macro2",
"quote",
"shaderc",
"syn",
"vulkano 0.34.0 (git+https://github.com/Molive-0/vulkano)",
]
[[package]]
name = "vulkano-shaders"
version = "0.34.0"
source = "git+https://github.com/vulkano-rs/vulkano.git#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
dependencies = [
"foldhash",
"heck 0.4.1",
@@ -2457,16 +2380,16 @@ dependencies = [
"quote",
"shaderc",
"syn",
"vulkano 0.34.0 (git+https://github.com/vulkano-rs/vulkano.git)",
"vulkano",
]
[[package]]
name = "vulkano-util"
version = "0.34.0"
source = "git+https://github.com/Molive-0/vulkano#9bb8ebd8b0c05c23eb83f92435c54ed130cfba97"
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
dependencies = [
"foldhash",
"vulkano 0.34.0 (git+https://github.com/Molive-0/vulkano)",
"vulkano",
"winit",
]
@@ -3177,9 +3100,9 @@ dependencies = [
[[patch.unused]]
name = "vulkano-taskgraph"
version = "0.34.0"
source = "git+https://github.com/Molive-0/vulkano#9bb8ebd8b0c05c23eb83f92435c54ed130cfba97"
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
[[patch.unused]]
name = "vulkano-win"
version = "0.34.0"
source = "git+https://github.com/Molive-0/vulkano#9bb8ebd8b0c05c23eb83f92435c54ed130cfba97"
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
+8 -7
View File
@@ -18,7 +18,7 @@ bytemuck = { version = "1.13", features = [
"min_const_generics",
] }
cgmath = "0.18"
glam = "0.29"
egui = "0.30"
egui_winit_vulkano = "0.27"
@@ -31,13 +31,14 @@ utf-8 = "0.7"
rayon = "1.7"
rand = "0.8.5"
foldhash = "0.1.4"
# using latest gits
[patch.crates-io]
vulkano = { git = "https://github.com/Molive-0/vulkano" }
vulkano-macros = { git = "https://github.com/Molive-0/vulkano" }
vulkano-shaders = { git = "https://github.com/Molive-0/vulkano" }
vulkano-taskgraph = { git = "https://github.com/Molive-0/vulkano" }
vulkano-util = { git = "https://github.com/Molive-0/vulkano" }
vulkano-win = { git = "https://github.com/Molive-0/vulkano" }
vulkano = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-macros = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-taskgraph = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-util = { git = "https://github.com/vulkano-rs/vulkano" }
vulkano-win = { git = "https://github.com/vulkano-rs/vulkano" }
egui_winit_vulkano = { git = "https://github.com/Molive-0/egui_winit_vulkano" }
+1 -1
View File
@@ -8,7 +8,7 @@
#ifdef implicit
layout (constant_id = 0) const bool DISABLE_TRACE = false;
layout (constant_id = 1) const bool BRUTE_FORCE = false;
layout (constant_id = 5) const bool BRUTE_FORCE = false;
layout(location=0)in VertexInput
{
+4 -4
View File
@@ -8,10 +8,10 @@ uint DescriptionIndex;
#include "include.glsl"
#include "intervals.glsl"
layout (constant_id = 0) const bool DISABLE_TRACE = false;
layout (constant_id = 1) const bool DISABLE_SCALING_1 = false;
layout (constant_id = 2) const bool DISABLE_SCALING_2 = false;
layout (constant_id = 3) const bool BRUTE_FORCE = false;
layout (constant_id = 1) const bool DISABLE_TRACE = false;
layout (constant_id = 2) const bool DISABLE_SCALING_1 = false;
layout (constant_id = 3) const bool DISABLE_SCALING_2 = false;
layout (constant_id = 5) const bool BRUTE_FORCE = false;
layout(local_size_x=32,local_size_y=1,local_size_z=1)in;
layout(triangles,max_vertices=256,max_primitives=192)out;
+1 -1
View File
@@ -8,7 +8,7 @@
#include "include.glsl"
#include "intervals.glsl"
layout (constant_id = 0) const bool DISABLE_TRACE = false;
layout (constant_id = 4) const bool DISABLE_TRACE = false;
layout(local_size_x=32,local_size_y=1,local_size_z=1)in;
+706 -482
View File
File diff suppressed because it is too large Load Diff
+64 -102
View File
@@ -2,21 +2,22 @@ use std::{
collections::HashMap,
io::{Cursor, Read},
mem,
sync::Arc,
};
use bytemuck::{Pod, Zeroable};
use cgmath::{
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, SquareMatrix, Vector2, Vector3,
Vector4,
};
use glam::{self, Mat2, Mat3, Mat4, Vec2, Vec3, Vec4};
use obj::{LoadConfig, ObjData, ObjError};
use serde::{Deserialize, Serialize};
use vulkano::{
buffer::{Buffer, BufferAllocateInfo, BufferUsage, Subbuffer},
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
memory::allocator::{
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
},
pipeline::graphics::vertex_input::Vertex,
};
use crate::{instruction_set::InstructionSet, mcsg_deserialise::from_reader, MemoryAllocator};
use crate::{instruction_set::InstructionSet, mcsg_deserialise::from_reader};
pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
pub(crate) const CSG_SOLIDS: [(&str, &[u8]); 1] =
@@ -40,27 +41,21 @@ pub(crate) struct Mesh {
pub(crate) name: String,
pub(crate) vertices: Subbuffer<[OVertex]>,
pub(crate) indices: Subbuffer<[u32]>,
pub(crate) pos: Point3<f32>,
pub(crate) rot: Euler<Deg<f32>>,
pub(crate) scale: Vector3<f32>,
pub(crate) pos: Vec3,
pub(crate) rot: Vec3,
pub(crate) scale: Vec3,
}
#[derive(Debug)]
pub(crate) struct CSG {
pub(crate) name: String,
pub(crate) parts: Vec<CSGPart>,
pub(crate) pos: Point3<f32>,
pub(crate) rot: Euler<Deg<f32>>,
pub(crate) scale: Vector3<f32>,
pub(crate) pos: Vec3,
pub(crate) rot: Vec3,
pub(crate) scale: Vec3,
}
pub(crate) type Float = f64;
pub(crate) type Vec2 = Vector2<Float>;
pub(crate) type Vec3 = Vector3<Float>;
pub(crate) type Vec4 = Vector4<Float>;
pub(crate) type Mat2 = Matrix2<Float>;
pub(crate) type Mat3 = Matrix3<Float>;
pub(crate) type Mat4 = Matrix4<Float>;
pub(crate) type Float = f32;
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub(crate) enum Inputs {
@@ -117,7 +112,7 @@ impl CSGPart {
}
pub(crate) fn load_obj(
memory_allocator: &MemoryAllocator,
memory_allocator: &Arc<StandardMemoryAllocator>,
input: &mut dyn Read,
name: String,
) -> Result<Vec<Mesh>, ObjError> {
@@ -154,9 +149,14 @@ pub(crate) fn load_obj(
}
let vertex_buffer = Buffer::from_iter(
memory_allocator,
BufferAllocateInfo {
buffer_usage: BufferUsage::VERTEX_BUFFER,
memory_allocator.clone(),
BufferCreateInfo {
usage: BufferUsage::VERTEX_BUFFER,
..Default::default()
},
AllocationCreateInfo {
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE,
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
..Default::default()
},
vertices,
@@ -164,9 +164,14 @@ pub(crate) fn load_obj(
.unwrap();
let index_buffer = Buffer::from_iter(
memory_allocator,
BufferAllocateInfo {
buffer_usage: BufferUsage::INDEX_BUFFER,
memory_allocator.clone(),
BufferCreateInfo {
usage: BufferUsage::INDEX_BUFFER,
..Default::default()
},
AllocationCreateInfo {
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE,
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
..Default::default()
},
indices,
@@ -176,17 +181,9 @@ pub(crate) fn load_obj(
Ok(vec![Mesh {
vertices: vertex_buffer,
indices: index_buffer,
pos: Point3 {
x: 0.,
y: 0.,
z: 0.,
},
rot: Euler::new(Deg(0.), Deg(0.), Deg(0.)),
scale: Vector3 {
x: 1.,
y: 1.,
z: 1.,
},
pos: Vec3::ZERO,
rot: Vec3::ZERO,
scale: Vec3::ONE,
name,
}])
}
@@ -200,42 +197,31 @@ type MCSGObject = HashMap<String, String>;
type MCSGCSG = Vec<MCSGCSGPart>;
type MCSGCSGPart = HashMap<String, String>;
fn matrix3_from_string(input: &str) -> Result<Matrix3<f32>, String> {
fn mat3_from_string(input: &str) -> Result<Mat3, String> {
let vec = input
.split(' ')
.map(|s| s.parse::<f32>())
.collect::<Result<Vec<f32>, _>>()
.map_err(|_| "not floats")?;
let array: [f32; 9] = vec.try_into().map_err(|_| "wrong number of values")?;
let matrix: &Matrix3<f32> = (&array).into();
Ok(*matrix)
let matrix = Mat3::from_cols_array(&array);
Ok(matrix)
}
fn vector3_from_string(input: &str) -> Result<Vector3<f32>, String> {
fn vec3_from_string(input: &str) -> Result<Vec3, String> {
let vec = input
.split(' ')
.map(|s| s.parse::<f32>())
.collect::<Result<Vec<f32>, _>>()
.map_err(|_| "not floats")?;
let array: [f32; 3] = vec.try_into().map_err(|_| "wrong number of values")?;
let vector: &Vector3<f32> = (&array).into();
Ok(*vector)
}
fn point3_from_string(input: &str) -> Result<Point3<f32>, String> {
let vec = input
.split(' ')
.map(|s| s.parse::<f32>())
.collect::<Result<Vec<f32>, _>>()
.map_err(|_| "not floats")?;
let array: [f32; 3] = vec.try_into().map_err(|_| "wrong number of values")?;
let point: &Point3<f32> = (&array).into();
Ok(*point)
let vector = Vec3::from_array(array);
Ok(vector)
}
struct TRS {
translation: Point3<f32>,
rotation: Matrix3<f32>,
scale: Vector3<f32>,
translation: Vec3,
rotation: Mat3,
scale: Vec3,
}
fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
@@ -243,49 +229,37 @@ fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
translation: o
.get("t")
.map(String::as_str)
.map(point3_from_string)
.map(vec3_from_string)
.transpose()?
.unwrap_or(Point3::origin()),
.unwrap_or(Vec3::ZERO),
rotation: o
.get("r")
.map(String::as_str)
.map(matrix3_from_string)
.map(mat3_from_string)
.transpose()?
.unwrap_or(Matrix3::identity()),
.unwrap_or(Mat3::IDENTITY),
scale: o
.get("s")
.map(String::as_str)
.map(vector3_from_string)
.map(vec3_from_string)
.transpose()?
.unwrap_or(Vector3 {
x: 1.,
y: 1.,
z: 1.,
}),
.unwrap_or(Vec3::ONE),
})
}
fn get_color(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
fn get_color(o: &HashMap<String, String>) -> Result<Vec3, String> {
Ok(o.get("color")
.map(String::as_str)
.map(vector3_from_string)
.map(vec3_from_string)
.transpose()?
.unwrap_or(Vector3 {
x: 255.,
y: 255.,
z: 255.,
}))
.unwrap_or(Vec3::splat(255.)))
}
fn get_rgb(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
fn get_rgb(o: &HashMap<String, String>) -> Result<Vec3, String> {
Ok(o.get("rgb")
.map(String::as_str)
.map(vector3_from_string)
.map(vec3_from_string)
.transpose()?
.unwrap_or(Vector3 {
x: 255.,
y: 255.,
z: 255.,
}))
.unwrap_or(Vec3::splat(255.)))
}
fn get_f32(o: &HashMap<String, String>, tag: &str) -> Result<f32, String> {
@@ -338,7 +312,7 @@ fn get_half(o: &HashMap<String, String>) -> Result<Half, String> {
}
pub(crate) fn load_csg(
_memory_allocator: &MemoryAllocator,
_memory_allocator: &Arc<StandardMemoryAllocator>,
input: &mut dyn Read,
name: String,
) -> Result<Vec<CSG>, String> {
@@ -388,17 +362,9 @@ pub(crate) fn load_csg(
Ok(CSG {
parts,
pos: Point3 {
x: 0.,
y: 0.,
z: 0.,
},
rot: Euler::new(Deg(0.), Deg(0.), Deg(0.)),
scale: Vector3 {
x: 1.,
y: 1.,
z: 1.,
},
pos: Vec3::ZERO,
rot: Vec3::ZERO,
scale: Vec3::ONE,
name,
})
})
@@ -407,13 +373,13 @@ pub(crate) fn load_csg(
#[derive(Debug)]
pub(crate) struct Light {
pub(crate) pos: Point3<f32>,
pub(crate) colour: Vector3<f32>,
pub(crate) pos: Vec3,
pub(crate) colour: Vec3,
}
impl Light {
pub(crate) fn new(pos: [f32; 3], colour: [f32; 3], intensity: f32) -> Light {
let c: Vector3<f32> = colour.into();
let c: Vec3 = colour.into();
Light {
pos: pos.into(),
colour: c * intensity,
@@ -424,12 +390,8 @@ impl Light {
impl Default for Light {
fn default() -> Self {
Self {
pos: Point3::origin(),
colour: Vector3 {
x: 1.,
y: 1.,
z: 1.,
},
pos: Vec3::ZERO,
colour: Vec3::ONE,
}
}
}