Reorder feedback buffer processing logic
This commit is contained in:
parent
cbc95df5cb
commit
ba973a7306
|
@ -179,16 +179,18 @@ impl BrickmapManager {
|
||||||
|
|
||||||
pub fn process_feedback_buffer(&mut self, context: &gfx::Context, world: &mut WorldManager) {
|
pub fn process_feedback_buffer(&mut self, context: &gfx::Context, world: &mut WorldManager) {
|
||||||
// Get request count
|
// Get request count
|
||||||
let data: Vec<u32> = self.feedback_result_buffer.get_mapped_range(context, 0..16);
|
let mut data: Vec<u32> = self.feedback_result_buffer.get_mapped_range(context, 0..16);
|
||||||
let request_count = data[1] as usize;
|
let request_count = data[1] as usize;
|
||||||
if request_count == 0 {
|
|
||||||
self.upload_unpack_buffers(context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the position data
|
// Getting the position data and resetting the request count is costly, so we
|
||||||
let range = 16..(16 + 16 * request_count as u64);
|
// only do it if there were actually any requests
|
||||||
let data: Vec<u32> = self.feedback_result_buffer.get_mapped_range(context, range);
|
if request_count > 0 {
|
||||||
|
let range = 16..(16 + 16 * request_count as u64);
|
||||||
|
data = self.feedback_result_buffer.get_mapped_range(context, range);
|
||||||
|
context
|
||||||
|
.queue
|
||||||
|
.write_buffer(&self.feedback_buffer, 4, &[0, 0, 0, 0]);
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a sphere of voxels
|
// Generate a sphere of voxels
|
||||||
let grid_dims = self.state_uniform.brickgrid_dims;
|
let grid_dims = self.state_uniform.brickgrid_dims;
|
||||||
|
@ -258,10 +260,7 @@ impl BrickmapManager {
|
||||||
self.brickmap_cache_idx = (self.brickmap_cache_idx + 1) % self.brickmap_cache_map.len();
|
self.brickmap_cache_idx = (self.brickmap_cache_idx + 1) % self.brickmap_cache_map.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the request count on the gpu buffer
|
// TODO: Why do we call this here rather than doing it outside of here?
|
||||||
let data = &[0, 0, 0, 0];
|
|
||||||
context.queue.write_buffer(&self.feedback_buffer, 4, data);
|
|
||||||
|
|
||||||
self.upload_unpack_buffers(context);
|
self.upload_unpack_buffers(context);
|
||||||
|
|
||||||
// TODO: This is inaccurate if we've looped
|
// TODO: This is inaccurate if we've looped
|
||||||
|
|
Loading…
Reference in New Issue