LIVE SHADER RELOADING!!
This commit is contained in:
+2
-1
@@ -3,4 +3,5 @@ pipeline_cache.bin
|
||||
log.log
|
||||
*.out.spv
|
||||
*.recompiled.spv
|
||||
*.spv-dis
|
||||
*.spv-dis
|
||||
shaders_out
|
||||
Generated
+92
@@ -844,6 +844,15 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fsevent-sys"
|
||||
version = "4.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gethostname"
|
||||
version = "1.1.0"
|
||||
@@ -1064,6 +1073,26 @@ dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"inotify-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inotify-sys"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "interpolate_name"
|
||||
version = "0.2.4"
|
||||
@@ -1132,6 +1161,26 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kqueue"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a"
|
||||
dependencies = [
|
||||
"kqueue-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kqueue-sys"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.3"
|
||||
@@ -1258,6 +1307,18 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "moxcms"
|
||||
version = "0.7.10"
|
||||
@@ -1335,6 +1396,30 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "8.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"fsevent-sys",
|
||||
"inotify",
|
||||
"kqueue",
|
||||
"libc",
|
||||
"log",
|
||||
"mio",
|
||||
"notify-types",
|
||||
"walkdir",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify-types"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d"
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.6"
|
||||
@@ -2443,6 +2528,7 @@ dependencies = [
|
||||
"foldhash",
|
||||
"glam",
|
||||
"log",
|
||||
"notify",
|
||||
"num_cpus",
|
||||
"obj",
|
||||
"rand",
|
||||
@@ -2790,6 +2876,12 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.1+wasi-0.2.4"
|
||||
|
||||
@@ -39,6 +39,8 @@ rspirv = "0.12"
|
||||
|
||||
num_cpus = "1"
|
||||
|
||||
notify = "8.2"
|
||||
|
||||
# using latest gits
|
||||
[patch.crates-io]
|
||||
#vulkano = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||
|
||||
+17
-11
@@ -1,15 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
glslangValidator --spirv-val --spirv-dis -g0 -S frag --target-env vulkan1.3 --quiet src/trace.frag.glsl > src/trace.spv-dis
|
||||
sed -i '/%11 =/,/OpFunctionEnd/d' src/trace.spv-dis
|
||||
sed -i 's/%11\b/%1000/g' src/trace.spv-dis
|
||||
spirv-as --preserve-numeric-ids --target-env vulkan1.3 -o src/trace.recompiled.spv src/trace.spv-dis
|
||||
rm frag.spv
|
||||
# rm src/trace.spv-dis
|
||||
mkdir -p shaders_out
|
||||
|
||||
glslangValidator --spirv-val --spirv-dis -g0 -S frag --target-env vulkan1.3 --quiet src/normals.frag.glsl > src/normals.spv-dis
|
||||
sed -i '/%11 =/,/OpFunctionEnd/d' src/normals.spv-dis
|
||||
sed -i 's/%11\b/%1000/g' src/normals.spv-dis
|
||||
spirv-as --preserve-numeric-ids --target-env vulkan1.3 -o src/normals.recompiled.spv src/normals.spv-dis
|
||||
glslangValidator --spirv-val -gVS -S vert --target-env vulkan1.3 -o shaders_out/fullscreen.vert.spv src/fullscreen.vert.glsl
|
||||
glslangValidator --spirv-val -gVS -S frag --target-env vulkan1.3 -o shaders_out/lighting.frag.spv src/lighting.frag.glsl
|
||||
glslangValidator --spirv-val -gVS -S vert --target-env vulkan1.3 -o shaders_out/trace.vert.spv src/trace.vert.glsl
|
||||
|
||||
glslangValidator --spirv-val --spirv-dis -g0 -S frag --target-env vulkan1.3 --quiet src/trace.frag.glsl > shaders_out/trace.spv-dis
|
||||
sed -i '/%11 =/,/OpFunctionEnd/d' shaders_out/trace.spv-dis
|
||||
sed -i 's/%11\b/%1000/g' shaders_out/trace.spv-dis
|
||||
spirv-as --preserve-numeric-ids --target-env vulkan1.3 -o shaders_out/trace.recompiled.spv shaders_out/trace.spv-dis
|
||||
rm frag.spv
|
||||
# rm src/normals.spv-dis
|
||||
# rm shaders_out/trace.spv-dis
|
||||
|
||||
glslangValidator --spirv-val --spirv-dis -g0 -S frag --target-env vulkan1.3 --quiet src/normals.frag.glsl > shaders_out/normals.spv-dis
|
||||
sed -i '/%11 =/,/OpFunctionEnd/d' shaders_out/normals.spv-dis
|
||||
sed -i 's/%11\b/%1000/g' shaders_out/normals.spv-dis
|
||||
spirv-as --preserve-numeric-ids --target-env vulkan1.3 -o shaders_out/normals.recompiled.spv shaders_out/normals.spv-dis
|
||||
rm frag.spv
|
||||
# rm shaders_out/normals.spv-dis
|
||||
|
||||
+12
-2
@@ -36,6 +36,8 @@ pub(crate) struct GState {
|
||||
pub(crate) lights: Vec<Light>,
|
||||
pub(crate) csg: Vec<Arc<RwLock<CSG>>>,
|
||||
|
||||
pub(crate) new_csg_needed: bool,
|
||||
|
||||
pub(crate) fps: [f64; 128],
|
||||
|
||||
pub(crate) debug: PreviousDebug,
|
||||
@@ -47,6 +49,8 @@ pub(crate) struct GState {
|
||||
pub(crate) sheen_tint: f32,
|
||||
pub(crate) clear_coat_gloss: f32,
|
||||
pub(crate) clear_coat: f32,
|
||||
|
||||
pub(crate) recreate_pipelines: bool,
|
||||
}
|
||||
|
||||
impl Default for GState {
|
||||
@@ -59,6 +63,8 @@ impl Default for GState {
|
||||
lights: vec![],
|
||||
csg: vec![],
|
||||
|
||||
new_csg_needed: false,
|
||||
|
||||
fps: [0.0; 128],
|
||||
|
||||
debug: Default::default(),
|
||||
@@ -70,11 +76,13 @@ impl Default for GState {
|
||||
clear_coat_gloss: 0.63,
|
||||
subsurface: 0.,
|
||||
clear_coat: 0.85,
|
||||
|
||||
recreate_pipelines: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState, new_csg_needed: &mut bool) {
|
||||
pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
gui.immediate_ui(|gui| {
|
||||
let ctx = gui.context();
|
||||
egui::SidePanel::left(Id::new("main_left"))
|
||||
@@ -220,7 +228,7 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState, new_csg_needed: &mut boo
|
||||
state.csg.remove(i);
|
||||
}
|
||||
if state.csg.len() < 32 && ui.small_button("add csg").clicked() {
|
||||
*new_csg_needed = true;
|
||||
state.new_csg_needed = true;
|
||||
}
|
||||
ui.heading(format!("Lights ({})", state.lights.len()));
|
||||
let mut lightdel = vec![];
|
||||
@@ -315,6 +323,8 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState, new_csg_needed: &mut boo
|
||||
&mut state.debug.use_linear_ao,
|
||||
"Use linear falloff for occlusion calculation",
|
||||
);
|
||||
|
||||
state.recreate_pipelines = ui.button("Force recompile pipelines").clicked();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+222
-64
@@ -18,7 +18,7 @@ use std::{
|
||||
fs::{File, remove_file, rename},
|
||||
io::{Cursor, Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, Mutex, mpmc, mpsc},
|
||||
sync::{Arc, Mutex, atomic::AtomicBool, mpmc, mpsc},
|
||||
thread::{self, JoinHandle},
|
||||
time::Instant,
|
||||
};
|
||||
@@ -28,6 +28,7 @@ use egui_winit_vulkano::{Gui, GuiConfig};
|
||||
use foldhash::{HashMap, HashMapExt, HashSet};
|
||||
use glam::{self, EulerRot, Mat3, Mat4, Vec3, vec3};
|
||||
use log::{error, info, trace};
|
||||
use notify::{RecommendedWatcher, Watcher};
|
||||
use rspirv::dr::Module;
|
||||
use simplelog::{CombinedLogger, Config, TermLogger, WriteLogger};
|
||||
use vulkano::{
|
||||
@@ -72,7 +73,7 @@ use vulkano::{
|
||||
layout::PipelineDescriptorSetLayoutCreateInfo,
|
||||
},
|
||||
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
||||
shader::{ShaderModule, SpecializationConstant},
|
||||
shader::{ShaderModule, ShaderModuleCreateInfo, SpecializationConstant},
|
||||
swapchain::{
|
||||
PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
|
||||
acquire_next_image,
|
||||
@@ -219,6 +220,8 @@ struct App {
|
||||
thread_work_creation: mpmc::Sender<WorkItem>,
|
||||
thread_work_completion: mpsc::Receiver<WorkComplete>,
|
||||
rcx: Arc<Mutex<Option<RenderContext>>>,
|
||||
watcher: RecommendedWatcher,
|
||||
glsl_changed: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -489,7 +492,7 @@ impl App {
|
||||
.wait(None)
|
||||
.unwrap();
|
||||
|
||||
let trace_spv_code = include_bytes!("trace.recompiled.spv");
|
||||
let trace_spv_code = include_bytes!("../shaders_out/trace.recompiled.spv");
|
||||
let trace_spv_code_u32 = trace_spv_code
|
||||
.as_chunks::<4>()
|
||||
.0
|
||||
@@ -500,7 +503,7 @@ impl App {
|
||||
rspirv::binary::parse_words(trace_spv_code_u32, &mut loader).unwrap();
|
||||
let trace_module = loader.module();
|
||||
|
||||
let normals_spv_code = include_bytes!("normals.recompiled.spv");
|
||||
let normals_spv_code = include_bytes!("../shaders_out/normals.recompiled.spv");
|
||||
let normals_spv_code_u32 = normals_spv_code
|
||||
.as_chunks::<4>()
|
||||
.0
|
||||
@@ -524,6 +527,45 @@ impl App {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let glsl_changed = Arc::new(AtomicBool::new(false));
|
||||
let watcher_glsl_changed = glsl_changed.clone();
|
||||
let mut watcher = notify::recommended_watcher(
|
||||
move |res: Result<notify::Event, notify::Error>| match res {
|
||||
Ok(event) => {
|
||||
//info!("event: {:?}", event);
|
||||
#[cfg(target_os = "linux")]
|
||||
match event.kind {
|
||||
notify::EventKind::Modify(notify::event::ModifyKind::Data(_)) => {
|
||||
info!("event: {:?}", event);
|
||||
watcher_glsl_changed.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
},
|
||||
Err(e) => error!("watch error: {:?}", e),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let paths = std::fs::read_dir("src").unwrap();
|
||||
for path in paths {
|
||||
if let Ok(path) = path {
|
||||
if path
|
||||
.path()
|
||||
.extension()
|
||||
.map(|ext| ext == "glsl")
|
||||
.unwrap_or(false)
|
||||
{
|
||||
watcher
|
||||
.watch(&path.path(), notify::RecursiveMode::NonRecursive)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
App {
|
||||
instance,
|
||||
device,
|
||||
@@ -550,14 +592,15 @@ impl App {
|
||||
thread_work_creation: thread_work_creation_sender,
|
||||
thread_work_completion: thread_work_completion_receiver,
|
||||
rcx: Arc::new(Mutex::new(None)),
|
||||
watcher,
|
||||
glsl_changed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod trace_vs {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "vertex",
|
||||
path: "src/trace.vert.glsl",
|
||||
bytes: "shaders_out/trace.vert.spv",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
@@ -566,8 +609,7 @@ mod trace_vs {
|
||||
|
||||
mod fullscreen_vs {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "vertex",
|
||||
path: "src/fullscreen.vert.glsl",
|
||||
bytes: "shaders_out/fullscreen.vert.spv",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
@@ -576,8 +618,7 @@ mod fullscreen_vs {
|
||||
|
||||
mod lighting_fs {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "fragment",
|
||||
path: "src/lighting.frag.glsl",
|
||||
bytes: "shaders_out/lighting.frag.spv",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
@@ -1367,6 +1408,123 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn load_all_spv_from_file(&mut self, rcx: &mut RenderContext) {
|
||||
let trace_frag = load_spv_from_file("trace.recompiled.spv");
|
||||
if trace_frag.is_err() {
|
||||
error!("Could not read trace frag file");
|
||||
return;
|
||||
}
|
||||
let trace_frag = trace_frag.unwrap();
|
||||
|
||||
let trace_vert = load_spv_from_file("trace.vert.spv");
|
||||
if trace_vert.is_err() {
|
||||
error!("Could not read trace vert file");
|
||||
return;
|
||||
}
|
||||
let trace_vert = trace_vert.unwrap();
|
||||
|
||||
let normals_frag = load_spv_from_file("normals.recompiled.spv");
|
||||
if normals_frag.is_err() {
|
||||
error!("Could not read normals frag file");
|
||||
return;
|
||||
}
|
||||
let normals_frag = normals_frag.unwrap();
|
||||
|
||||
let fullscreen_vert = load_spv_from_file("fullscreen.vert.spv");
|
||||
if fullscreen_vert.is_err() {
|
||||
error!("Could not read fullscreen vert file");
|
||||
return;
|
||||
}
|
||||
let fullscreen_vert = fullscreen_vert.unwrap();
|
||||
|
||||
let lighting_frag = load_spv_from_file("lighting.frag.spv");
|
||||
if lighting_frag.is_err() {
|
||||
error!("Could not read lighting frag file");
|
||||
return;
|
||||
}
|
||||
let lighting_frag = lighting_frag.unwrap();
|
||||
|
||||
let mut trace_loader = rspirv::dr::Loader::new();
|
||||
rspirv::binary::parse_words(trace_frag, &mut trace_loader).unwrap();
|
||||
|
||||
let mut normals_loader = rspirv::dr::Loader::new();
|
||||
rspirv::binary::parse_words(normals_frag, &mut normals_loader).unwrap();
|
||||
|
||||
let trace_vert = unsafe {
|
||||
::vulkano::shader::ShaderModule::new(
|
||||
self.device.clone(),
|
||||
ShaderModuleCreateInfo::new(&trace_vert),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let fullscreen_vert = unsafe {
|
||||
::vulkano::shader::ShaderModule::new(
|
||||
self.device.clone(),
|
||||
ShaderModuleCreateInfo::new(&fullscreen_vert),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let lighting_frag = unsafe {
|
||||
::vulkano::shader::ShaderModule::new(
|
||||
self.device.clone(),
|
||||
ShaderModuleCreateInfo::new(&lighting_frag),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
rcx.shader_modules = ShaderModules {
|
||||
trace_vs: trace_vert,
|
||||
fullscreen_vs: fullscreen_vert,
|
||||
lighting_fs: lighting_frag,
|
||||
};
|
||||
|
||||
self.trace_module = trace_loader.module();
|
||||
self.normals_module = normals_loader.module();
|
||||
}
|
||||
|
||||
fn recreate_pipelines(
|
||||
&mut self,
|
||||
rcx: &mut RenderContext,
|
||||
work_for_later: &mut Vec<WorkComplete>,
|
||||
) {
|
||||
self.load_all_spv_from_file(rcx);
|
||||
|
||||
let mut csg_left = self.gstate.csg.len();
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::RecompilePipelines(
|
||||
csg.clone(),
|
||||
self.device.clone(),
|
||||
self.trace_module.clone(),
|
||||
self.normals_module.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug.clone(),
|
||||
i,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
rcx.lighting_pipeline = pipeline_recompile(
|
||||
&rcx.render_pass,
|
||||
&self.pipeline_cache,
|
||||
&rcx.shader_modules,
|
||||
&self.gstate.debug,
|
||||
);
|
||||
while csg_left > 0 {
|
||||
for work in self.thread_work_completion.try_iter() {
|
||||
match work {
|
||||
WorkComplete::RecompilePipelines(_index) => {
|
||||
csg_left -= 1;
|
||||
},
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn redraw(&mut self, rcx: &mut RenderContext) {
|
||||
let window_size = rcx.window.inner_size();
|
||||
if window_size.width == 0 || window_size.height == 0 {
|
||||
@@ -1389,33 +1547,50 @@ impl App {
|
||||
|
||||
rcx.render_start = Instant::now();
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
if self.glsl_changed.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
self.glsl_changed
|
||||
.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
if std::process::Command::new("bash")
|
||||
.arg("assemble_trace.sh")
|
||||
.status()
|
||||
.is_err()
|
||||
{
|
||||
error!("Could not compile shaders");
|
||||
}
|
||||
rcx.recreate_pipelines = true;
|
||||
}
|
||||
|
||||
let mut work_for_later = vec![];
|
||||
|
||||
if self.draw_gui {
|
||||
let mut csg_needed = false;
|
||||
gui_up(&mut rcx.gui, &mut self.gstate, &mut csg_needed);
|
||||
if csg_needed {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::CreateCSG(
|
||||
self.device.clone(),
|
||||
self.trace_module.clone(),
|
||||
self.normals_module.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug.clone(),
|
||||
self.block_enable_allocator.clone(),
|
||||
self.host_visible_allocator.clone(),
|
||||
self.descriptor_set_allocator.clone(),
|
||||
rcx.swapchain.image_count(),
|
||||
DEFAULT_SUBDIVISION,
|
||||
rand::random(),
|
||||
-1,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
gui_up(&mut rcx.gui, &mut self.gstate);
|
||||
}
|
||||
|
||||
if self.gstate.new_csg_needed {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::CreateCSG(
|
||||
self.device.clone(),
|
||||
self.trace_module.clone(),
|
||||
self.normals_module.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug.clone(),
|
||||
self.block_enable_allocator.clone(),
|
||||
self.host_visible_allocator.clone(),
|
||||
self.descriptor_set_allocator.clone(),
|
||||
rcx.swapchain.image_count(),
|
||||
DEFAULT_SUBDIVISION,
|
||||
rand::random(),
|
||||
-1,
|
||||
))
|
||||
.unwrap();
|
||||
self.gstate.new_csg_needed = false;
|
||||
}
|
||||
|
||||
rcx.recreate_pipelines |= self.gstate.recreate_pipelines;
|
||||
|
||||
let mut push_constants = vec![
|
||||
PushConstantData {
|
||||
world: Default::default(),
|
||||
@@ -1465,38 +1640,7 @@ impl App {
|
||||
}
|
||||
|
||||
if rcx.recreate_pipelines {
|
||||
let mut csg_left = self.gstate.csg.len();
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::RecompilePipelines(
|
||||
csg.clone(),
|
||||
self.device.clone(),
|
||||
self.trace_module.clone(),
|
||||
self.normals_module.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug.clone(),
|
||||
i,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
rcx.lighting_pipeline = pipeline_recompile(
|
||||
&rcx.render_pass,
|
||||
&self.pipeline_cache,
|
||||
&rcx.shader_modules,
|
||||
&self.gstate.debug,
|
||||
);
|
||||
while csg_left > 0 {
|
||||
for work in self.thread_work_completion.try_iter() {
|
||||
match work {
|
||||
WorkComplete::RecompilePipelines(_index) => {
|
||||
csg_left -= 1;
|
||||
},
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
}
|
||||
self.recreate_pipelines(rcx, &mut work_for_later);
|
||||
rcx.recreate_pipelines = false;
|
||||
}
|
||||
|
||||
@@ -1927,6 +2071,7 @@ fn get_spec_constants(debug: &PreviousDebug) -> HashMap<u32, SpecializationConst
|
||||
|
||||
spec_constants
|
||||
}
|
||||
|
||||
fn pipeline_recompile(
|
||||
render_pass: &Arc<RenderPass>,
|
||||
cache: &Arc<PipelineCache>,
|
||||
@@ -2130,3 +2275,16 @@ fn get_pipeline_cache(device: Arc<Device>) -> Arc<PipelineCache> {
|
||||
fn relpath(path: &str) -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join(path)
|
||||
}
|
||||
|
||||
fn load_spv_from_file(name: &str) -> std::io::Result<Vec<u32>> {
|
||||
let mut spv_file = std::fs::File::open(format!("shaders_out/{name}"))?;
|
||||
let mut buf = vec![];
|
||||
spv_file.read_to_end(&mut buf)?;
|
||||
let spv_code_u32 = buf
|
||||
.as_chunks::<4>()
|
||||
.0
|
||||
.into_iter()
|
||||
.map(|u| u32::from_le_bytes(*u))
|
||||
.collect::<Vec<_>>();
|
||||
Ok(spv_code_u32)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#version 460
|
||||
#extension GL_GOOGLE_include_directive:require
|
||||
#include "include.glsl"
|
||||
#include "implicit_include.glsl"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user