Refactor upload_unpack_buffers
This commit is contained in:
parent
23ea18c3de
commit
66f44c5461
|
@ -297,24 +297,24 @@ impl BrickmapManager {
|
||||||
self.brickgrid_staged.insert(index);
|
self.brickgrid_staged.insert(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Tidy this up more
|
||||||
fn upload_unpack_buffers(&mut self, context: &gfx::Context) {
|
fn upload_unpack_buffers(&mut self, context: &gfx::Context) {
|
||||||
// Brickgrid
|
// Brickgrid
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
let mut iter = self.brickgrid_staged.iter();
|
let mut iter = self.brickgrid_staged.iter();
|
||||||
let mut to_remove = Vec::new();
|
let mut to_remove = Vec::new();
|
||||||
for _ in 0..self.unpack_max_count {
|
for _ in 0..self.unpack_max_count {
|
||||||
let el = iter.next();
|
match iter.next() {
|
||||||
if el.is_none() {
|
Some(val) => {
|
||||||
break;
|
to_remove.push(*val);
|
||||||
}
|
|
||||||
|
|
||||||
let val = el.unwrap();
|
|
||||||
to_remove.push(*val as u32);
|
|
||||||
data.push(*val as u32);
|
data.push(*val as u32);
|
||||||
data.push(self.brickgrid[*val]);
|
data.push(self.brickgrid[*val]);
|
||||||
}
|
}
|
||||||
|
None => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
for val in &to_remove {
|
for val in &to_remove {
|
||||||
self.brickgrid_staged.remove(&(*val as usize));
|
self.brickgrid_staged.remove(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !data.is_empty() {
|
if !data.is_empty() {
|
||||||
|
@ -328,12 +328,7 @@ impl BrickmapManager {
|
||||||
context.queue.write_buffer(
|
context.queue.write_buffer(
|
||||||
&self.brickgrid_unpack_buffer,
|
&self.brickgrid_unpack_buffer,
|
||||||
4,
|
4,
|
||||||
bytemuck::cast_slice(&[data.len()]),
|
bytemuck::cast_slice(&[&[data.len() as u32, 0, 0], &data[..]].concat()),
|
||||||
);
|
|
||||||
context.queue.write_buffer(
|
|
||||||
&self.brickgrid_unpack_buffer,
|
|
||||||
16,
|
|
||||||
bytemuck::cast_slice(&data),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Brickmap
|
// Brickmap
|
||||||
|
|
Loading…
Reference in New Issue