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