atagen

monolith

public
Star0
Watch0

Commit 04fc1116cfba

tarball

atagen <boss@atagen.co>2026-10-19 10:36 UTC

1 file changed+6-5
render-vk: size non-coherent flushes to the allocation

Staging::host_sync passed WHOLE_SIZE, so flushing or invalidating one buffer covered every neighbouring suballocation in the block, including ones the import worker was writing. Allocations are now rounded to the atom size and alignment up front, which lets the range be exactly the allocation.
Modified file: crates/render-vk/src/staging.rs+6 additions−5 deletions
@@ -7,7 +7,7 @@ use std::sync::{Arc, Mutex};
77 use std::time::{Duration, Instant};
88
99 /// Pooled staging memory kept at most, past which dropped buffers are freed.
10-const POOL_BYTES: usize = 32 * 1024 * 1024;
10+pub(crate) const POOL_BYTES: usize = 32 * 1024 * 1024;
1111
1212 /// How long a pooled buffer may go unused before it is freed.
1313 const POOL_IDLE: Duration = Duration::from_secs(2);
@@ -128,7 +128,9 @@ impl Staging {
128128 None,
129129 )?
130130 };
131- let requirements = unsafe { d.get_buffer_memory_requirements(buffer) };
131+ let mut requirements = unsafe { d.get_buffer_memory_requirements(buffer) };
132+ requirements.size = requirements.size.next_multiple_of(pool.atom);
133+ requirements.alignment = requirements.alignment.max(pool.atom);
132134 let allocation = pool
133135 .shared
134136 .allocator
@@ -184,11 +186,10 @@ impl Staging {
184186 {
185187 return Ok(());
186188 }
187- let atom = self.pool.atom;
188189 let range = [vk::MappedMemoryRange::default()
189190 .memory(unsafe { allocation.memory() })
190- .offset(allocation.offset() / atom * atom)
191- .size(vk::WHOLE_SIZE)];
191+ .offset(allocation.offset())
192+ .size(allocation.size())];
192193 let d = &self.pool.shared.device.device;
193194 unsafe {
194195 if flush {