Deterministic CSG
This commit is contained in:
+3
-1
@@ -270,7 +270,7 @@ impl App {
|
||||
enabled_extensions: InstanceExtensions {
|
||||
..required_extensions
|
||||
},
|
||||
engine_name: Some("ImplEng".to_owned()),
|
||||
engine_name: Some("Tape Drive".to_owned()),
|
||||
engine_version: Version::major_minor(0, 1),
|
||||
application_name: Some(env!("CARGO_PKG_NAME").to_owned()),
|
||||
application_version: app_version(),
|
||||
@@ -949,6 +949,7 @@ impl ApplicationHandler for App {
|
||||
self.descriptor_set_allocator.clone(),
|
||||
rcx.swapchain.image_count(),
|
||||
DEFAULT_SUBDIVISION,
|
||||
rand::random(),
|
||||
0,
|
||||
))
|
||||
.unwrap();
|
||||
@@ -1407,6 +1408,7 @@ impl App {
|
||||
self.descriptor_set_allocator.clone(),
|
||||
rcx.swapchain.image_count(),
|
||||
DEFAULT_SUBDIVISION,
|
||||
rand::random(),
|
||||
-1,
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
@@ -39,6 +39,7 @@ pub(crate) struct Mesh {
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct CSG {
|
||||
pub(crate) name: String,
|
||||
pub(crate) seed: u64,
|
||||
pub(crate) parts: SSATape,
|
||||
pub(crate) pos: Vec3,
|
||||
pub(crate) rot: Vec3,
|
||||
|
||||
+3
-3
@@ -457,7 +457,7 @@ impl SSATape {
|
||||
} else {
|
||||
let mut b = rspirv::dr::Builder::new();
|
||||
b.set_version(1, 6);
|
||||
b.module_processed(format!("ImplEng JIT {JIT_VERSION}"));
|
||||
b.module_processed(format!("Tape Drive JIT {JIT_VERSION}"));
|
||||
b.memory_model(spirv::AddressingModel::Logical, spirv::MemoryModel::GLSL450);
|
||||
b
|
||||
};
|
||||
@@ -493,8 +493,8 @@ impl SSATape {
|
||||
if with_module { Some(1000) } else { None },
|
||||
//spirv::FunctionControl::DONT_INLINE
|
||||
spirv::FunctionControl::INLINE
|
||||
| spirv::FunctionControl::PURE
|
||||
| spirv::FunctionControl::CONST,
|
||||
| spirv::FunctionControl::PURE
|
||||
| spirv::FunctionControl::CONST,
|
||||
point_fn_type,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
+13
-8
@@ -9,6 +9,7 @@ use std::{
|
||||
use foldhash::HashSet;
|
||||
use glam::{EulerRot, Mat4, Vec3};
|
||||
use log::info;
|
||||
use rand::{Rng, SeedableRng, rngs::SmallRng};
|
||||
use rspirv::{binary::Assemble, dr::Module};
|
||||
use vulkano::{
|
||||
buffer::{Subbuffer, allocator::SubbufferAllocator},
|
||||
@@ -63,6 +64,7 @@ pub enum WorkItem {
|
||||
Arc<StandardDescriptorSetAllocator>,
|
||||
u32,
|
||||
u32,
|
||||
u64,
|
||||
isize,
|
||||
),
|
||||
GetPushConstants(
|
||||
@@ -106,10 +108,11 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
descriptor_set_allocator,
|
||||
frames,
|
||||
subdivision,
|
||||
seed,
|
||||
index,
|
||||
) => {
|
||||
let csg_start = Instant::now();
|
||||
let parts = create_csg();
|
||||
let parts = create_csg(seed);
|
||||
|
||||
let trace_shader_module =
|
||||
sdf_specialize_module(device.clone(), &parts, trace_module, &format!("trace"));
|
||||
@@ -187,6 +190,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,
|
||||
parts,
|
||||
pos: Vec3::ZERO,
|
||||
rot: Vec3::ZERO,
|
||||
@@ -418,7 +422,8 @@ fn deferred_pipelines_recompile(
|
||||
(trace_pipeline, normals_pipeline)
|
||||
}
|
||||
|
||||
fn create_csg() -> SSATape {
|
||||
fn create_csg(seed: u64) -> SSATape {
|
||||
let mut rng = SmallRng::seed_from_u64(seed);
|
||||
let mut tape = SSATape::default();
|
||||
let pos = tape.push_instruction(
|
||||
SSAOpcodeSized {
|
||||
@@ -436,9 +441,9 @@ fn create_csg() -> SSATape {
|
||||
pos[0],
|
||||
pos[1],
|
||||
pos[2],
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rng.random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rng.random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rng.random_range(0.0..1.0)),
|
||||
],
|
||||
);
|
||||
let sphere = tape.push_instruction(
|
||||
@@ -450,7 +455,7 @@ fn create_csg() -> SSATape {
|
||||
offset[0],
|
||||
offset[1],
|
||||
offset[2],
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rng.random_range(0.0..1.0)),
|
||||
],
|
||||
);
|
||||
let torus = tape.push_instruction(
|
||||
@@ -462,8 +467,8 @@ fn create_csg() -> SSATape {
|
||||
pos[0],
|
||||
pos[1],
|
||||
pos[2],
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rng.random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rng.random_range(0.0..1.0)),
|
||||
],
|
||||
);
|
||||
let min = tape.push_instruction(
|
||||
|
||||
Reference in New Issue
Block a user