split recompile pipelines
This commit is contained in:
@@ -218,13 +218,11 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
ui.label("Subdivision");
|
||||
for x in MINUMUM_SUBDIVISION.ilog2()..=MAXIMUM_SUBDIVISION.ilog2() {
|
||||
let subdivision = 1 << x;
|
||||
csg.new_pipelines_needed |= ui
|
||||
.selectable_value(
|
||||
&mut csg.subdivision,
|
||||
subdivision,
|
||||
format!("{}", subdivision),
|
||||
)
|
||||
.clicked();
|
||||
ui.selectable_value(
|
||||
&mut csg.subdivision,
|
||||
subdivision,
|
||||
format!("{}", subdivision),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+36
-43
@@ -679,10 +679,12 @@ impl App {
|
||||
};
|
||||
}
|
||||
|
||||
define_replacement_module!("trace.frag");
|
||||
define_replacement_module!("normals.frag");
|
||||
define_replacement_module!("fuzz.comp");
|
||||
define_replacement_module!("enable_gen.comp");
|
||||
define_replacement_module!("fuzz.comp");
|
||||
define_replacement_module!("normals.frag");
|
||||
define_replacement_module!("normals.rchit");
|
||||
define_replacement_module!("trace.frag");
|
||||
define_replacement_module!("trace.rint");
|
||||
|
||||
let replacement_modules = Arc::new(RwLock::new(replacement_modules));
|
||||
|
||||
@@ -1715,6 +1717,7 @@ impl App {
|
||||
},
|
||||
WorkComplete::GetPushConstants(..) => {},
|
||||
WorkComplete::RecompilePipelines(..) => {},
|
||||
WorkComplete::RecompileShaders(..) => {},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1829,21 +1832,42 @@ impl App {
|
||||
) {
|
||||
self.load_all_spv_from_file(rcx);
|
||||
|
||||
let mut csg_left = self.gstate.csg.len();
|
||||
let mut csg_shaders_left = self.gstate.csg.len();
|
||||
let mut csg_pipelines_left = self.gstate.csg.len();
|
||||
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::RecompilePipelines(
|
||||
.send(WorkItem::RecompileShaders(
|
||||
csg.clone(),
|
||||
self.device.clone(),
|
||||
self.replacement_modules.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug,
|
||||
i,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
while csg_shaders_left > 0 {
|
||||
for work in self.thread_work_completion.try_iter() {
|
||||
match work {
|
||||
WorkComplete::RecompileShaders(index) => {
|
||||
csg_shaders_left -= 1;
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::RecompilePipelines(
|
||||
self.gstate.csg[index].clone(),
|
||||
self.device.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug,
|
||||
index,
|
||||
))
|
||||
.unwrap();
|
||||
},
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(
|
||||
rcx.lighting_pipeline,
|
||||
rcx.rt_pipeline,
|
||||
@@ -1855,11 +1879,12 @@ impl App {
|
||||
&rcx.shader_modules,
|
||||
&self.gstate.debug,
|
||||
);
|
||||
while csg_left > 0 {
|
||||
|
||||
while csg_pipelines_left > 0 {
|
||||
for work in self.thread_work_completion.try_iter() {
|
||||
match work {
|
||||
WorkComplete::RecompilePipelines(_index) => {
|
||||
csg_left -= 1;
|
||||
csg_pipelines_left -= 1;
|
||||
},
|
||||
other => work_for_later.push(other),
|
||||
}
|
||||
@@ -2178,38 +2203,6 @@ impl App {
|
||||
rcx.recreate_pipelines = false;
|
||||
}
|
||||
|
||||
{
|
||||
let mut csg_left = 0;
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
let rcsg = csg.read().unwrap();
|
||||
if rcsg.new_pipelines_needed {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::RecompilePipelines(
|
||||
csg.clone(),
|
||||
self.device.clone(),
|
||||
self.replacement_modules.clone(),
|
||||
rcx.render_pass.clone(),
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug,
|
||||
i,
|
||||
))
|
||||
.unwrap();
|
||||
csg_left += 1;
|
||||
}
|
||||
}
|
||||
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.move_camera();
|
||||
|
||||
let (image_index, suboptimal, acquire_future) =
|
||||
|
||||
@@ -53,7 +53,6 @@ pub(crate) struct CSG {
|
||||
pub(crate) colour: Vec3,
|
||||
pub(crate) roughness: f32,
|
||||
pub(crate) metallic: f32,
|
||||
pub(crate) new_pipelines_needed: bool,
|
||||
pub(crate) replacement_modules: Arc<RwLock<HashMap<String, Arc<ShaderModule>>>>,
|
||||
pub(crate) trace_pipeline: Arc<GraphicsPipeline>,
|
||||
pub(crate) normals_pipeline: Arc<GraphicsPipeline>,
|
||||
|
||||
+30
-16
@@ -76,10 +76,15 @@ pub enum WorkItem {
|
||||
bool,
|
||||
usize,
|
||||
),
|
||||
RecompilePipelines(
|
||||
RecompileShaders(
|
||||
Arc<RwLock<CSG>>,
|
||||
Arc<Device>,
|
||||
Arc<RwLock<HashMap<String, Module>>>,
|
||||
usize,
|
||||
),
|
||||
RecompilePipelines(
|
||||
Arc<RwLock<CSG>>,
|
||||
Arc<Device>,
|
||||
Arc<RenderPass>,
|
||||
Arc<PipelineCache>,
|
||||
Arc<RwLock<HashMap<String, Arc<ShaderModule>>>>,
|
||||
@@ -91,6 +96,7 @@ pub enum WorkItem {
|
||||
pub enum WorkComplete {
|
||||
CreateCSG(Arc<RwLock<CSG>>, isize),
|
||||
GetPushConstants(PushConstantData, Box<dyn GpuFuture + Send + Sync>, usize),
|
||||
RecompileShaders(usize),
|
||||
RecompilePipelines(usize),
|
||||
}
|
||||
|
||||
@@ -224,7 +230,6 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
pos: Vec3::ZERO,
|
||||
rot: Vec3::ZERO,
|
||||
scale: Vec3::ONE,
|
||||
new_pipelines_needed: false,
|
||||
replacement_modules,
|
||||
trace_pipeline,
|
||||
normals_pipeline,
|
||||
@@ -292,18 +297,9 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
))
|
||||
.unwrap();
|
||||
},
|
||||
WorkItem::RecompilePipelines(
|
||||
csg,
|
||||
device,
|
||||
replacement_modules,
|
||||
render_pass,
|
||||
cache,
|
||||
normal_modules,
|
||||
debug,
|
||||
index,
|
||||
) => {
|
||||
WorkItem::RecompileShaders(csg, device, replacement_modules, index) => {
|
||||
let csg_start = Instant::now();
|
||||
let mut csg = csg.write().unwrap();
|
||||
let csg = csg.read().unwrap();
|
||||
|
||||
let mut new_replacement_modules = csg.replacement_modules.write().unwrap();
|
||||
new_replacement_modules.clear();
|
||||
@@ -314,8 +310,26 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
new_replacement_modules.insert(name.clone(), specialised_module);
|
||||
}
|
||||
|
||||
drop(new_replacement_modules);
|
||||
send.send(WorkComplete::RecompileShaders(index)).unwrap();
|
||||
|
||||
let csg_end = Instant::now();
|
||||
info!(
|
||||
"CSG {} shader recompile took {} milliseconds",
|
||||
index,
|
||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||
);
|
||||
},
|
||||
WorkItem::RecompilePipelines(
|
||||
csg,
|
||||
device,
|
||||
render_pass,
|
||||
cache,
|
||||
normal_modules,
|
||||
debug,
|
||||
index,
|
||||
) => {
|
||||
let csg_start = Instant::now();
|
||||
let mut csg = csg.write().unwrap();
|
||||
(
|
||||
csg.trace_pipeline,
|
||||
csg.normals_pipeline,
|
||||
@@ -330,12 +344,12 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
debug,
|
||||
);
|
||||
|
||||
csg.new_pipelines_needed = false;
|
||||
send.send(WorkComplete::RecompilePipelines(index)).unwrap();
|
||||
|
||||
let csg_end = Instant::now();
|
||||
info!(
|
||||
"CSG recompile took {} milliseconds",
|
||||
"CSG {} pipeline recompile took {} milliseconds",
|
||||
index,
|
||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user