split out shaders

This commit is contained in:
2026-11-11 20:56:03 +00:00
parent d4bdb18a14
commit 8c87c549d3
5 changed files with 252 additions and 117 deletions
@@ -251,13 +251,8 @@ pub fn compile_raytracing_blas(
struct PushConstants {
aabb_buffer_offset: u32,
metadata_buffer_offset: u32,
flags: u32,
}
const FLAG_FILL_ENABLE_GEN: u32 = 1 << 0;
const FLAG_FILL_SPATIAL_TEXTURE: u32 = 1 << 1;
const FLAG_FILL_TILETREE: u32 = 1 << 2;
let tape_info = tapes
.iter()
.filter(|(asset_id, _)| blas_manager.needs_new_blas.contains(asset_id))
@@ -295,42 +290,65 @@ pub fn compile_raytracing_blas(
.iter()
.filter_map(
|(key, tape, aabbs_slice, metadata_slice, spatial_texture, tiletree, blas_size)| {
let pipeline = pipeline_cache.get_compute_pipeline(tape.enable_gen_pipeline)?;
let enable_gen_pipeline =
pipeline_cache.get_compute_pipeline(tape.enable_gen_pipeline)?;
let spatial_texture_pipeline =
pipeline_cache.get_compute_pipeline(tape.spatial_texture_pipeline)?;
let tiletree_pipeline =
pipeline_cache.get_compute_pipeline(tape.tiletree_pipeline)?;
let bind_group = render_device.create_bind_group(
let enable_gen_bind_group = render_device.create_bind_group(
"enable_gen_bind_group",
&pipeline_cache.get_bind_group_layout(&replacement_modules.enable_gen_layout),
&BindGroupEntries::sequential((
aabbs_slice.buffer.as_entire_buffer_binding(),
metadata_slice.buffer.as_entire_buffer_binding(),
aabbs_slice.buffer.as_entire_buffer_binding(),
)),
);
let spatial_texture_bind_group = render_device.create_bind_group(
"spatial_texture_bind_group",
&pipeline_cache
.get_bind_group_layout(&replacement_modules.spatial_texture_layout),
&BindGroupEntries::sequential((
metadata_slice.buffer.as_entire_buffer_binding(),
&spatial_texture.1,
)),
);
let tiletree_bind_group = render_device.create_bind_group(
"tiletree_bind_group",
&pipeline_cache.get_bind_group_layout(&replacement_modules.tiletree_layout),
&BindGroupEntries::sequential((
metadata_slice.buffer.as_entire_buffer_binding(),
aabbs_slice.buffer.as_entire_buffer_binding(),
&spatial_texture.1,
&tiletree.1,
)),
);
let mut pc = PushConstants {
let pc = PushConstants {
aabb_buffer_offset: aabbs_slice.range.start,
metadata_buffer_offset: metadata_slice.range.start,
flags: FLAG_FILL_ENABLE_GEN,
};
compute_pass.set_pipeline(pipeline);
compute_pass.set_bind_group(0, &bind_group, &[]);
compute_pass.set_pipeline(enable_gen_pipeline);
compute_pass.set_immediates(0, bytemuck::bytes_of(&pc));
compute_pass.set_bind_group(0, &enable_gen_bind_group, &[]);
compute_pass.dispatch_workgroups(
tape.subdivision / 4,
tape.subdivision / 4,
tape.subdivision / 4,
);
pc.flags = FLAG_FILL_SPATIAL_TEXTURE;
compute_pass.set_immediates(0, bytemuck::bytes_of(&pc));
compute_pass.set_pipeline(spatial_texture_pipeline);
compute_pass.set_bind_group(0, &spatial_texture_bind_group, &[]);
compute_pass.dispatch_workgroups(
tape.subdivision * 2,
tape.subdivision * 2,
tape.subdivision * 2,
);
pc.flags = FLAG_FILL_TILETREE;
compute_pass.set_immediates(0, bytemuck::bytes_of(&pc));
compute_pass.set_pipeline(tiletree_pipeline);
compute_pass.set_bind_group(0, &tiletree_bind_group, &[]);
compute_pass.dispatch_workgroups(
(tape.subdivision / 4) * 128,
(tape.subdivision / 4) * 128,