Spatial texture writing works
This commit is contained in:
@@ -745,7 +745,7 @@ impl InstanceState {
|
||||
return false;
|
||||
}
|
||||
|
||||
let spatial_texture_key = spatial_texture.id();
|
||||
let spatial_texture_key = spatial_texture.0.id();
|
||||
let spatial_capacity = MAX_SPATIAL_TEXTURE_COUNT.get();
|
||||
if !self
|
||||
.spatial_textures
|
||||
@@ -774,13 +774,7 @@ impl InstanceState {
|
||||
let spatial_texture_id = self
|
||||
.spatial_textures
|
||||
.acquire(spatial_texture_key, spatial_capacity, || {
|
||||
spatial_texture.create_view(&TextureViewDescriptor {
|
||||
label: Some(&format!(
|
||||
"Tape {} slot {} spatial texture view",
|
||||
instance.tape, instance.slot
|
||||
)),
|
||||
..Default::default()
|
||||
})
|
||||
spatial_texture.1.clone()
|
||||
})
|
||||
.expect("spatial vslab binding array had room but handed out no slot");
|
||||
instance.buffers = Some((aabb_buffer_key, metadata_buffer_key, spatial_texture_key));
|
||||
|
||||
@@ -243,9 +243,12 @@ pub fn compile_raytracing_blas(
|
||||
struct PushConstants {
|
||||
aabb_buffer_offset: u32,
|
||||
metadata_buffer_offset: u32,
|
||||
time: f32,
|
||||
flags: u32,
|
||||
}
|
||||
|
||||
const FLAG_FILL_ENABLE_GEN: u32 = 1 << 0;
|
||||
const FLAG_FILL_SPATIAL_TEXTURE: u32 = 1 << 1;
|
||||
|
||||
let tape_info = tapes
|
||||
.iter()
|
||||
.filter(|(asset_id, _)| blas_manager.needs_new_blas.contains(asset_id))
|
||||
@@ -257,13 +260,21 @@ pub fn compile_raytracing_blas(
|
||||
|
||||
let aabbs_slice = tape_allocator.tape_aabb_slice(&asset_id).unwrap();
|
||||
let metadata_slice = tape_allocator.tape_metadata_slice(&asset_id).unwrap();
|
||||
let spatial_texture = tape_allocator.tape_spatial_texture(&asset_id).unwrap();
|
||||
|
||||
let blas_size = BlasAABBGeometrySizeDescriptor {
|
||||
primitive_count: aabbs_slice.range.len() as u32,
|
||||
flags: key.opacity.geometry_flags(),
|
||||
};
|
||||
|
||||
(key, tape, aabbs_slice, metadata_slice, blas_size)
|
||||
(
|
||||
key,
|
||||
tape,
|
||||
aabbs_slice,
|
||||
metadata_slice,
|
||||
spatial_texture,
|
||||
blas_size,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -271,42 +282,45 @@ pub fn compile_raytracing_blas(
|
||||
let mut updated_blases = vec![];
|
||||
let build_entries = tape_info
|
||||
.iter()
|
||||
.filter_map(|(key, tape, aabbs_slice, metadata_slice, blas_size)| {
|
||||
let pipeline = pipeline_cache.get_compute_pipeline(tape.enable_gen_pipeline)?;
|
||||
.filter_map(
|
||||
|(key, tape, aabbs_slice, metadata_slice, spatial_texture, blas_size)| {
|
||||
let pipeline = pipeline_cache.get_compute_pipeline(tape.enable_gen_pipeline)?;
|
||||
|
||||
let 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(),
|
||||
)),
|
||||
);
|
||||
let 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(),
|
||||
&spatial_texture.1,
|
||||
)),
|
||||
);
|
||||
|
||||
let pc = PushConstants {
|
||||
aabb_buffer_offset: aabbs_slice.range.start,
|
||||
metadata_buffer_offset: metadata_slice.range.start,
|
||||
time: 0.0,
|
||||
};
|
||||
let pc = PushConstants {
|
||||
aabb_buffer_offset: aabbs_slice.range.start,
|
||||
metadata_buffer_offset: metadata_slice.range.start,
|
||||
flags: FLAG_FILL_ENABLE_GEN | FLAG_FILL_SPATIAL_TEXTURE,
|
||||
};
|
||||
|
||||
compute_pass.set_pipeline(pipeline);
|
||||
compute_pass.set_bind_group(0, &bind_group, &[]);
|
||||
compute_pass.set_immediates(0, bytemuck::bytes_of(&pc));
|
||||
compute_pass.dispatch_workgroups(1, 1, 1);
|
||||
compute_pass.set_pipeline(pipeline);
|
||||
compute_pass.set_bind_group(0, &bind_group, &[]);
|
||||
compute_pass.set_immediates(0, bytemuck::bytes_of(&pc));
|
||||
compute_pass.dispatch_workgroups(1, 1, 1);
|
||||
|
||||
updated_blases.push(key.tape);
|
||||
updated_blases.push(key.tape);
|
||||
|
||||
let geometry = BlasAabbGeometry {
|
||||
size: blas_size,
|
||||
stride: size_of::<bevy_tape_load::render::PackedAabb>() as u64,
|
||||
aabb_buffer: aabbs_slice.buffer,
|
||||
primitive_offset: aabbs_slice.range.start,
|
||||
};
|
||||
Some(BlasBuildEntry {
|
||||
blas: blas_manager.get(&key).unwrap(),
|
||||
geometry: BlasGeometries::AabbGeometries(vec![geometry]),
|
||||
})
|
||||
})
|
||||
let geometry = BlasAabbGeometry {
|
||||
size: blas_size,
|
||||
stride: size_of::<bevy_tape_load::render::PackedAabb>() as u64,
|
||||
aabb_buffer: aabbs_slice.buffer,
|
||||
primitive_offset: aabbs_slice.range.start,
|
||||
};
|
||||
Some(BlasBuildEntry {
|
||||
blas: blas_manager.get(&key).unwrap(),
|
||||
geometry: BlasGeometries::AabbGeometries(vec![geometry]),
|
||||
})
|
||||
},
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
drop(compute_pass);
|
||||
|
||||
Reference in New Issue
Block a user