This commit is contained in:
2026-01-31 17:55:39 +00:00
parent 1acafae017
commit 5dbda08424
2 changed files with 40 additions and 20 deletions
+17 -13
View File
@@ -1122,6 +1122,8 @@ impl ApplicationHandler for App {
&self.memory_allocator,
&self.command_buffer_allocator,
&self.gstate.meshes,
&self.gstate.csg,
0,
);
let (
@@ -2289,14 +2291,6 @@ impl App {
self.gstate.new_csgs_needed -= 1;
}
rcx.scene = Scene::new(
&self.device,
&self.compute_queue,
&self.memory_allocator,
&self.command_buffer_allocator,
&self.gstate.meshes,
);
rcx.recreate_pipelines |= self.gstate.recreate_pipelines;
let mut push_constants = vec![
@@ -2405,6 +2399,16 @@ impl App {
let image_index = image_index as usize;
rcx.scene = Scene::new(
&self.device,
&self.compute_queue,
&self.memory_allocator,
&self.command_buffer_allocator,
&self.gstate.meshes,
&self.gstate.csg,
image_index,
);
let mut push_constants_left = self.gstate.csg.len();
for (i, csg) in self.gstate.csg.iter().enumerate() {
self.thread_work_creation
@@ -2465,11 +2469,6 @@ impl App {
let mut futures = camera_and_lights.boxed();
if RUN_RT_PIPELINE {
self.add_commands_raytrace(&mut builder, rcx, rt_set1, rt_set2, rt_set3, rt_set4);
}
if RUN_STANDARD_PIPELINE {
if !self.gstate.csg.is_empty() {
self.add_commands_enable_gen(
&mut builder,
@@ -2479,6 +2478,11 @@ impl App {
);
}
if RUN_RT_PIPELINE {
self.add_commands_raytrace(&mut builder, rcx, rt_set1, rt_set2, rt_set3, rt_set4);
}
if RUN_STANDARD_PIPELINE {
let depth_clear = if self.depth_format.numeric_format_stencil().is_some() {
Some((0.0, 0).into())
} else {
+19 -3
View File
@@ -1,4 +1,8 @@
use std::{iter, mem::size_of, sync::Arc};
use std::{
iter,
mem::size_of,
sync::{Arc, RwLock},
};
use vulkano::{
Packed24_8,
@@ -38,6 +42,8 @@ impl Scene {
memory_allocator: &Arc<dyn MemoryAllocator>,
command_buffer_allocator: &Arc<dyn CommandBufferAllocator>,
meshes: &[Mesh],
csgs: &[Arc<RwLock<CSG>>],
image_index: usize,
) -> Self {
// For simplicity, we build a single command buffer that builds the acceleration
// structure, then waits for its execution to complete.
@@ -55,7 +61,7 @@ impl Scene {
// contains the instances of the bottom-level acceleration structures. In our
// shader, we will trace rays against the top-level acceleration
// structure.
let blases: Vec<Arc<AccelerationStructure>> = meshes
let mut blases: Vec<Arc<AccelerationStructure>> = meshes
.iter()
.map(|mesh| unsafe {
build_acceleration_structure_triangles(
@@ -66,6 +72,15 @@ impl Scene {
)
})
.collect();
blases.extend(csgs.iter().map(|csg| unsafe {
build_acceleration_structure_boxes(
csg,
image_index,
memory_allocator.clone(),
device.clone(),
&mut builder,
)
}));
let blas_fence = builder
.build()
@@ -245,12 +260,13 @@ unsafe fn build_acceleration_structure_triangles(
}
unsafe fn build_acceleration_structure_boxes(
csg: &CSG,
csg: &Arc<RwLock<CSG>>,
index: usize,
memory_allocator: Arc<dyn MemoryAllocator>,
device: Arc<Device>,
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
) -> Arc<AccelerationStructure> {
let csg = csg.read().unwrap();
let primitive_count = (csg.subdivision * csg.subdivision * csg.subdivision) as u32;
let as_geometry_aabb_data = AccelerationStructureGeometryAabbsData {
stride: 4 * 6, // six floats