-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically growing scratch allocator & exposed image memory type #68
Conversation
…nt ``GfxSupport``
01_basic example works, and all tests pass.
} else { | ||
Err(anyhow::Error::from(Error::UnmappableBuffer)) | ||
if chunk_size % alignment != 0 { | ||
anyhow::bail!("Chunk size must be a multiple of alignment"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document this requirement in the function docs
src/allocator/scratch_allocator.rs
Outdated
buffers: Vec::new(), | ||
local_offset: 0, | ||
chunk_size, | ||
current_buffer: None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid hitches on the first draw it might make sense to allocate a single chunk on construction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. What should be the size of said initial chunk though? Or should it be used configured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one chunk of chunk_size
bytes no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would work yep. I guess it would create a dedicated buffer for allocations larger than chunk_size, and not use the default init one
src/allocator/scratch_allocator.rs
Outdated
let size: u64 = size.into(); | ||
|
||
// Round up to the preferred alignment value | ||
let padded_size = ((size as f32) / (256 as f32)).ceil() as u64 * 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this 256
be hardcoded here instead of using the stored alignment value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stored alignment value. I forgor
src/allocator/scratch_allocator.rs
Outdated
let whole_buffer_size = size.max(self.chunk_size); | ||
let buffer = Buffer::new(self.device.clone(), &mut self.allocator, whole_buffer_size, MemoryType::CpuToGpu)?; | ||
if !buffer.is_mapped() { | ||
return Err(anyhow::Error::from(Error::UnmappableBuffer)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bail!
I'd also add a method to shrink a scratch allocator to a given size. This should be similar to |
How would that work though? Since the allocator itself contains multiple small allocations of variable size (unless you'd want them to always be of size |
I figured |
Should fix both #66 and #38
I shoulda split it into two branches tbh.