@@ -1965,23 +1965,23 @@ typedef enum VmaPoolCreateFlagBits {
19651965 (wasted memory). In that case, if you can make sure you always allocate only
19661966 buffers and linear images or only optimal images out of this pool, use this flag
19671967 to make allocator disregard Buffer-Image Granularity and so make allocations
1968- more optimal.
1968+ faster and more optimal.
19691969 */
19701970 VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT = 0x00000002 ,
19711971
19721972 /* * \brief Enables alternative, linear allocation algorithm in this pool.
19731973
1974- Specify this flag to enable linear allocation algorithm, which always creates
1975- new allocations after last one and doesn't reuse space from allocations freed in
1976- between. It trades memory consumption for simplified algorithm and data
1977- structure, which has better performance and uses less memory for metadata.
1974+ Specify this flag to enable linear allocation algorithm, which always creates
1975+ new allocations after last one and doesn't reuse space from allocations freed in
1976+ between. It trades memory consumption for simplified algorithm and data
1977+ structure, which has better performance and uses less memory for metadata.
19781978
1979- By using this flag, you can achieve behavior of free-at-once, stack,
1980- ring buffer, and double stack. For details, see documentation chapter
1981- \ref linear_algorithm.
1979+ By using this flag, you can achieve behavior of free-at-once, stack,
1980+ ring buffer, and double stack. For details, see documentation chapter
1981+ \ref linear_algorithm.
19821982
1983- When using this flag, you must specify VmaPoolCreateInfo::maxBlockCount == 1 (or 0 for default).
1984- */
1983+ When using this flag, you must specify VmaPoolCreateInfo::maxBlockCount == 1 (or 0 for default).
1984+ */
19851985 VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT = 0x00000004 ,
19861986
19871987 /* * TODO */
@@ -9392,6 +9392,16 @@ bool VmaBlockMetadata_Buddy::CreateAllocationRequest(
93929392{
93939393 VMA_ASSERT (!upperAddress && " VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT can be used only with linear algorithm." );
93949394
9395+ // Simple way to respect bufferImageGranularity. May be optimized some day.
9396+ // Whenever it might be an OPTIMAL image...
9397+ if (allocType == VMA_SUBALLOCATION_TYPE_UNKNOWN ||
9398+ allocType == VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN ||
9399+ allocType == VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL)
9400+ {
9401+ allocAlignment = VMA_MAX (allocAlignment, bufferImageGranularity);
9402+ allocSize = VMA_MAX (allocSize, bufferImageGranularity);
9403+ }
9404+
93959405 if (allocSize > m_UsableSize)
93969406 {
93979407 return false ;
0 commit comments