Skip to content

Conversation

@lolzballs
Copy link
Contributor

This assert is not useful -- the size returned by the implementation is not supposed to be aligned. The alignment is for sub-allocating resources within a device memory allocation. In addition, allocations of memory from vkAllocateMemory are guaranteed to be aligned to the largest memory alignment requirement.

Fixes #51.

This assert is not useful -- the size returned by the implementation is
not supposed to be aligned. The alignment is for sub-allocating
resources within a device memory allocation. In addition, allocations of
memory from vkAllocateMemory are guaranteed to be aligned to the largest
memory alignment requirement.

Fixes KhronosGroup#51.
@dabrain34 dabrain34 requested a review from zlatinski December 9, 2025 11:28
@dabrain34
Copy link
Contributor

can you please @zlatinski give your feedback on this assert ? what was the initial idea on having it ?

@dabrain34
Copy link
Contributor

Can you backport this patch from NVPro as it is more complete ?

@lolzballs
Copy link
Contributor Author

Can you backport this patch from NVPro as it is more complete ?

@zlatinski, I'm not sure why allocationSize needs to be aligned? The only VU that indicates allocationSize needs to be aligned is VUID-VkMemoryAllocateInfo-allocationSize-01745, which doesn't apply to us because we are not importing.

@zlatinski
Copy link
Contributor

Please see 1a45c233e5461a39a2b09189d62f12a2370e313f from NVPRO samples.
vulkan: fix memory allocation size alignment in CreateDeviceMemory

@lolzballs
Copy link
Contributor Author

Please see 1a45c233e5461a39a2b09189d62f12a2370e313f from NVPRO samples. vulkan: fix memory allocation size alignment in CreateDeviceMemory

@zlatinski, in that change you align allocationSize, but there is no requirement that it be aligned. Can you please double check why you added it in NVPRO?

@zlatinski
Copy link
Contributor

in that change you align allocationSize, but there is no requirement that it be aligned. Can you please double check why you added it in NVPRO?

This is per the API specifying the alignment within the memoryRequirements.alignment, which is usually coming from vkGetBufferMemoryRequirements(device, buffer, &memoryRequirements).

@lolzballs
Copy link
Contributor Author

in that change you align allocationSize, but there is no requirement that it be aligned. Can you please double check why you added it in NVPRO?

This is per the API specifying the alignment within the memoryRequirements.alignment, which is usually coming from vkGetBufferMemoryRequirements(device, buffer, &memoryRequirements).

The VkMemoryRequirements::alignment refers to the the alignment within an allocation for the buffer. i.e. if you allocate a big chunk of memory and you want to suballocate within it, each buffer must be at an offset that is aligned to VkMemoryRequirements::alignment.

AFAIK (and confirmed with validation layers) there is no requirement for the allocation size to the aligned to VkMemoryRequirements::alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RADV: Encoder: H264 the encoding process fails with memory issues

3 participants