@@ -278,20 +278,27 @@ impl Default for AllocatorDebugSettings {
278278
279279/// The sizes of the memory blocks that the allocator will create.
280280///
281- /// Useful for tuning the allocator to your application's needs. For example most games will be fine with the defaultsize
281+ /// Useful for tuning the allocator to your application's needs. For example most games will be fine with the default
282282/// values, but eg. an app might want to use smaller block sizes to reduce the amount of memory used.
283283///
284284/// Clamped between 4MB and 256MB, and rounds up to the nearest multiple of 4MB for alignment reasons.
285285///
286+ /// Note that these limits only apply to shared memory blocks that can hold multiple allocations.
287+ /// If an allocation does not fit within the corresponding maximum block size, it will be placed
288+ /// in a dedicated memory block holding only this allocation, without limitations other than what
289+ /// the underlying hardware and driver are able to provide.
290+ ///
286291/// # Fixed or growable block size
287292///
288293/// This structure represents ranges of allowed sizes for shared memory blocks.
289- /// By default, If the bounds of a given range are equal, the allocator will
290- /// be configured to used a fixed memory block size for shared allocations.
294+ /// By default, if the upper bounds are not extended using `with_max_*_memblock_size`,
295+ /// the allocator will be configured to use a fixed memory block size for shared
296+ /// allocations.
291297///
292298/// Otherwise, the allocator will pick a memory block size within the specifed
293- /// range, dependending on the number of existing allocations for the memory
299+ /// range, depending on the number of existing allocations for the memory
294300/// type.
301+ ///
295302/// As a rule of thumb, the allocator will start with the minimum block size
296303/// and double the size with each new allocation, up to the specified maximum
297304/// block size. This growth is tracked independently for each memory type.
@@ -315,28 +322,36 @@ impl Default for AllocatorDebugSettings {
315322/// ```
316323#[ derive( Clone , Copy , Debug ) ]
317324pub struct AllocationSizes {
318- /// The initial size of the memory blocks that will be created for the GPU only memory type.
325+ /// The initial size for device memory blocks.
326+ ///
327+ /// The size of new device memory blocks doubles each time a new block is needed, up to
328+ /// [`AllocationSizes::max_device_memblock_size`].
319329 ///
320330 /// Defaults to 256MB.
321331 min_device_memblock_size : u64 ,
322- /// The size of device memory blocks doubles each time a new allocation is needed, up to
323- /// `device_maximum_memblock_size`.
332+ /// The maximum size for device memory blocks.
333+ ///
334+ /// Defaults to the value of [`AllocationSizes::min_device_memblock_size`].
324335 max_device_memblock_size : u64 ,
325- /// The size of the memory blocks that will be created for the CPU visible memory types.
336+ /// The initial size for host memory blocks.
337+ ///
338+ /// The size of new host memory blocks doubles each time a new block is needed, up to
339+ /// [`AllocationSizes::max_host_memblock_size`].
326340 ///
327341 /// Defaults to 64MB.
328342 min_host_memblock_size : u64 ,
329- /// The size of host memory blocks doubles each time a new allocation is needed, up to
330- /// `host_maximum_memblock_size`.
343+ /// The maximum size for host memory blocks.
344+ ///
345+ /// Defaults to the value of [`AllocationSizes::min_host_memblock_size`].
331346 max_host_memblock_size : u64 ,
332347}
333348
334349impl AllocationSizes {
335350 /// Sets the minimum device and host memory block sizes.
336351 ///
337352 /// The maximum block sizes are initialized to the minimum sizes and
338- /// can be changed using ` with_max_device_memblock_size` and
339- /// ` with_max_host_memblock_size`.
353+ /// can be increased using [`AllocationSizes:: with_max_device_memblock_size`] and
354+ /// [`AllocationSizes:: with_max_host_memblock_size`] .
340355 pub fn new ( device_memblock_size : u64 , host_memblock_size : u64 ) -> Self {
341356 let device_memblock_size = Self :: adjust_memblock_size ( device_memblock_size, "Device" ) ;
342357 let host_memblock_size = Self :: adjust_memblock_size ( host_memblock_size, "Host" ) ;
@@ -385,8 +400,11 @@ impl AllocationSizes {
385400 }
386401
387402 /// Used internally to decide the size of a shared memory block
388- /// based withing the allowed range, based on the number of
389- /// existing allocations
403+ /// based within the allowed range, based on the number of
404+ /// existing allocations. The more blocks there already are
405+ /// (where the requested allocation didn't fit), the larger
406+ /// the returned memory block size is going to be (up to
407+ /// `max_*_memblock_size`).
390408 pub ( crate ) fn get_memblock_size ( & self , is_host : bool , count : usize ) -> u64 {
391409 let ( min_size, max_size) = if is_host {
392410 ( self . min_host_memblock_size , self . max_host_memblock_size )
0 commit comments