fix directory

This commit is contained in:
2025-12-20 00:13:32 +00:00
parent d34b6eef07
commit 75bc063c8f
2 changed files with 66 additions and 66 deletions
+2 -1
View File
@@ -9,7 +9,8 @@ import re
SHADERS_DIR = "shaders_out" SHADERS_DIR = "shaders_out"
TARGET_ENV = "vulkan1.3" TARGET_ENV = "vulkan1.3"
shutil.rmtree(SHADERS_DIR) if os.path.isdir(SHADERS_DIR):
shutil.rmtree(SHADERS_DIR)
os.mkdir(SHADERS_DIR) os.mkdir(SHADERS_DIR)
normal_shaders = [ normal_shaders = [
+64 -65
View File
@@ -1,4 +1,3 @@
#![feature(variant_count)]
#![feature(portable_simd)] #![feature(portable_simd)]
#![feature(mpmc_channel)] #![feature(mpmc_channel)]
@@ -156,18 +155,18 @@ struct Keys {
struct CState { struct CState {
position: Vec3, position: Vec3,
forward: Vec3, forward: Vec3,
looking: bool, looking: bool,
keys: Keys, keys: Keys,
} }
impl Default for CState { impl Default for CState {
fn default() -> Self { fn default() -> Self {
CState { CState {
position: vec3(0., 0., 3.), position: vec3(0., 0., 3.),
forward: vec3(0., 0., 0.), forward: vec3(0., 0., 0.),
looking: false, looking: false,
keys: Keys { keys: Keys {
w: false, w: false,
s: false, s: false,
a: false, a: false,
@@ -234,12 +233,12 @@ struct App {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct ShaderModules { struct ShaderModules {
trace_vs: Arc<ShaderModule>, trace_vs: Arc<ShaderModule>,
fullscreen_vs: Arc<ShaderModule>, fullscreen_vs: Arc<ShaderModule>,
lighting_fs: Arc<ShaderModule>, lighting_fs: Arc<ShaderModule>,
raygen: Arc<ShaderModule>, raygen: Arc<ShaderModule>,
closest_hit: Arc<ShaderModule>, closest_hit: Arc<ShaderModule>,
miss: Arc<ShaderModule>, miss: Arc<ShaderModule>,
} }
struct RenderContext { struct RenderContext {
@@ -560,10 +559,10 @@ impl App {
notify::EventKind::Modify(notify::event::ModifyKind::Data(_)) => { notify::EventKind::Modify(notify::event::ModifyKind::Data(_)) => {
info!("event: {:?}", event); info!("event: {:?}", event);
watcher_glsl_changed.store(true, std::sync::atomic::Ordering::SeqCst); watcher_glsl_changed.store(true, std::sync::atomic::Ordering::SeqCst);
}, }
_ => {}, _ => {}
} }
}, }
Err(e) => error!("watch error: {:?}", e), Err(e) => error!("watch error: {:?}", e),
}, },
) )
@@ -823,12 +822,12 @@ impl ApplicationHandler for App {
.map(|load| load(self.device.clone()).unwrap()); .map(|load| load(self.device.clone()).unwrap());
let shader_modules = ShaderModules { let shader_modules = ShaderModules {
trace_vs: pariter.next().unwrap(), trace_vs: pariter.next().unwrap(),
fullscreen_vs: pariter.next().unwrap(), fullscreen_vs: pariter.next().unwrap(),
lighting_fs: pariter.next().unwrap(), lighting_fs: pariter.next().unwrap(),
raygen: pariter.next().unwrap(), raygen: pariter.next().unwrap(),
closest_hit: pariter.next().unwrap(), closest_hit: pariter.next().unwrap(),
miss: pariter.next().unwrap(), miss: pariter.next().unwrap(),
}; };
drop(pariter); drop(pariter);
@@ -892,8 +891,8 @@ impl ApplicationHandler for App {
.unwrap(); .unwrap();
let viewport = Viewport { let viewport = Viewport {
offset: [0.0, window_size.height as f32], 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 * -1.],
depth_range: 0.0..=1.0, depth_range: 0.0..=1.0,
}; };
@@ -959,8 +958,8 @@ impl ApplicationHandler for App {
images[0].format(), images[0].format(),
GuiConfig { GuiConfig {
allow_srgb_render_target: true, allow_srgb_render_target: true,
is_overlay: true, is_overlay: true,
samples: SampleCount::Sample1, samples: SampleCount::Sample1,
}, },
); );
@@ -1025,16 +1024,16 @@ impl ApplicationHandler for App {
match &event { match &event {
WindowEvent::CloseRequested => { WindowEvent::CloseRequested => {
event_loop.exit(); event_loop.exit();
}, }
WindowEvent::Resized(_) => { WindowEvent::Resized(_) => {
rcx.recreate_swapchain = true; rcx.recreate_swapchain = true;
}, }
WindowEvent::ScaleFactorChanged { .. } => { WindowEvent::ScaleFactorChanged { .. } => {
rcx.recreate_swapchain = true; rcx.recreate_swapchain = true;
}, }
WindowEvent::DroppedFile(_file) => { WindowEvent::DroppedFile(_file) => {
todo!() todo!()
}, }
WindowEvent::MouseInput { WindowEvent::MouseInput {
device_id: d, device_id: d,
state: s, state: s,
@@ -1045,7 +1044,7 @@ impl ApplicationHandler for App {
if b == &MouseButton::Right { if b == &MouseButton::Right {
self.cstate.looking = s == &ElementState::Pressed; self.cstate.looking = s == &ElementState::Pressed;
} }
}, }
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
device_id: _, device_id: _,
event: input, event: input,
@@ -1053,19 +1052,19 @@ impl ApplicationHandler for App {
} => match input.physical_key { } => match input.physical_key {
PhysicalKey::Code(KeyCode::KeyW) => { PhysicalKey::Code(KeyCode::KeyW) => {
self.cstate.keys.w = input.state == ElementState::Pressed; self.cstate.keys.w = input.state == ElementState::Pressed;
}, }
PhysicalKey::Code(KeyCode::KeyS) => { PhysicalKey::Code(KeyCode::KeyS) => {
self.cstate.keys.s = input.state == ElementState::Pressed; self.cstate.keys.s = input.state == ElementState::Pressed;
}, }
PhysicalKey::Code(KeyCode::KeyA) => { PhysicalKey::Code(KeyCode::KeyA) => {
self.cstate.keys.a = input.state == ElementState::Pressed; self.cstate.keys.a = input.state == ElementState::Pressed;
}, }
PhysicalKey::Code(KeyCode::KeyD) => { PhysicalKey::Code(KeyCode::KeyD) => {
self.cstate.keys.d = input.state == ElementState::Pressed; self.cstate.keys.d = input.state == ElementState::Pressed;
}, }
PhysicalKey::Code(KeyCode::ShiftLeft) => { PhysicalKey::Code(KeyCode::ShiftLeft) => {
self.cstate.looking = input.state == ElementState::Pressed; self.cstate.looking = input.state == ElementState::Pressed;
}, }
PhysicalKey::Code(KeyCode::Space) => { PhysicalKey::Code(KeyCode::Space) => {
if input.state == ElementState::Pressed { if input.state == ElementState::Pressed {
self.thread_work_creation self.thread_work_creation
@@ -1087,18 +1086,18 @@ impl ApplicationHandler for App {
)) ))
.unwrap(); .unwrap();
} }
}, }
PhysicalKey::Code(KeyCode::KeyG) => { PhysicalKey::Code(KeyCode::KeyG) => {
if input.state == ElementState::Pressed { if input.state == ElementState::Pressed {
self.draw_gui = !self.draw_gui; self.draw_gui = !self.draw_gui;
} }
}, }
_ => {}, _ => {}
}, },
WindowEvent::RedrawRequested => { WindowEvent::RedrawRequested => {
self.redraw(rcx); self.redraw(rcx);
}, }
_ => {}, _ => {}
} }
} }
@@ -1169,23 +1168,23 @@ impl App {
* Mat4::from_translation(Vec3::ZERO - self.cstate.position); * Mat4::from_translation(Vec3::ZERO - self.cstate.position);
let uniform_data = trace_vs::Camera { let uniform_data = trace_vs::Camera {
proj_view: (proj * view).to_cols_array_2d(), proj_view: (proj * view).to_cols_array_2d(),
inv_proj_view: (proj * view).inverse().to_cols_array_2d(), inv_proj_view: (proj * view).inverse().to_cols_array_2d(),
inv_proj: (proj).inverse().to_cols_array_2d(), inv_proj: (proj).inverse().to_cols_array_2d(),
inv_view: (view).inverse().to_cols_array_2d(), inv_view: (view).inverse().to_cols_array_2d(),
campos_and_time: [ campos_and_time: [
self.cstate.position.x, self.cstate.position.x,
self.cstate.position.y, self.cstate.position.y,
self.cstate.position.z, self.cstate.position.z,
self.time, self.time,
], ],
specular: self.gstate.specular.into(), specular: self.gstate.specular.into(),
specular_tint: self.gstate.specular_tint.into(), specular_tint: self.gstate.specular_tint.into(),
sheen_tint: self.gstate.sheen_tint.into(), sheen_tint: self.gstate.sheen_tint.into(),
sheen: self.gstate.sheen.into(), sheen: self.gstate.sheen.into(),
clear_coat_gloss: self.gstate.clear_coat_gloss.into(), clear_coat_gloss: self.gstate.clear_coat_gloss.into(),
subsurface: self.gstate.subsurface.into(), subsurface: self.gstate.subsurface.into(),
clear_coat: self.gstate.clear_coat.into(), clear_coat: self.gstate.clear_coat.into(),
}; };
if self.cstate.looking { if self.cstate.looking {
@@ -1537,9 +1536,9 @@ impl App {
} else { } else {
self.gstate.csg[index as usize] = csg; self.gstate.csg[index as usize] = csg;
} }
}, }
WorkComplete::GetPushConstants(..) => {}, WorkComplete::GetPushConstants(..) => {}
WorkComplete::RecompilePipelines(..) => {}, WorkComplete::RecompilePipelines(..) => {}
} }
} }
@@ -1706,7 +1705,7 @@ impl App {
match work { match work {
WorkComplete::RecompilePipelines(_index) => { WorkComplete::RecompilePipelines(_index) => {
csg_left -= 1; csg_left -= 1;
}, }
other => work_for_later.push(other), other => work_for_later.push(other),
} }
} }
@@ -1781,7 +1780,7 @@ impl App {
let mut push_constants = vec![ let mut push_constants = vec![
PushConstantData { PushConstantData {
world: Default::default(), world: Default::default(),
inv_world: Default::default(), inv_world: Default::default(),
}; };
self.gstate.csg.len() self.gstate.csg.len()
@@ -1858,7 +1857,7 @@ impl App {
match work { match work {
WorkComplete::RecompilePipelines(_index) => { WorkComplete::RecompilePipelines(_index) => {
csg_left -= 1; csg_left -= 1;
}, }
other => work_for_later.push(other), other => work_for_later.push(other),
} }
} }
@@ -1873,7 +1872,7 @@ impl App {
Err(VulkanError::OutOfDate) => { Err(VulkanError::OutOfDate) => {
rcx.recreate_swapchain = true; rcx.recreate_swapchain = true;
return; return;
}, }
Err(e) => panic!("Failed to acquire next image: {e}"), Err(e) => panic!("Failed to acquire next image: {e}"),
}; };
@@ -1976,7 +1975,7 @@ impl App {
Some(future.boxed()) Some(future.boxed())
}; };
push_constants_left -= 1; push_constants_left -= 1;
}, }
other => work_for_later.push(other), other => work_for_later.push(other),
} }
} }
@@ -2051,20 +2050,20 @@ impl App {
match future.map_err(Validated::unwrap) { match future.map_err(Validated::unwrap) {
Ok(future) => { Ok(future) => {
rcx.previous_frame_end[image_index] = Some(future); rcx.previous_frame_end[image_index] = Some(future);
}, }
Err(VulkanError::OutOfDate) => { Err(VulkanError::OutOfDate) => {
rcx.recreate_swapchain = true; rcx.recreate_swapchain = true;
rcx.previous_frame_end[image_index] = None; rcx.previous_frame_end[image_index] = None;
}, }
Err(e) => { Err(e) => {
error!("Failed to flush future: {e:?}"); error!("Failed to flush future: {e:?}");
rcx.previous_frame_end[image_index] = None; rcx.previous_frame_end[image_index] = None;
}, }
} }
for work in self.thread_work_completion.try_iter() { for work in self.thread_work_completion.try_iter() {
match work { match work {
WorkComplete::GetPushConstants(..) => {}, WorkComplete::GetPushConstants(..) => {}
other => work_for_later.push(other), other => work_for_later.push(other),
} }
} }
@@ -2110,8 +2109,8 @@ fn framebuffer_generation(
depth_buffer.clone(), depth_buffer.clone(),
ImageViewCreateInfo { ImageViewCreateInfo {
subresource_range: ImageSubresourceRange { subresource_range: ImageSubresourceRange {
aspects: ImageAspects::DEPTH, aspects: ImageAspects::DEPTH,
mip_levels: 0..1, mip_levels: 0..1,
array_layers: 0..1, array_layers: 0..1,
}, },
..ImageViewCreateInfo::from_image(&depth_buffer.clone()) ..ImageViewCreateInfo::from_image(&depth_buffer.clone())
@@ -2407,7 +2406,7 @@ fn pipeline_recompile(
RayTracingShaderGroupCreateInfo::General { general_shader: 1 }, RayTracingShaderGroupCreateInfo::General { general_shader: 1 },
RayTracingShaderGroupCreateInfo::TrianglesHit { RayTracingShaderGroupCreateInfo::TrianglesHit {
closest_hit_shader: Some(2), closest_hit_shader: Some(2),
any_hit_shader: None, any_hit_shader: None,
}, },
]; ];