Skip to content

Comments

common: remove assert for memory alignment#120

Open
lolzballs wants to merge 2 commits intoKhronosGroup:mainfrom
lolzballs:mem-align
Open

common: remove assert for memory alignment#120
lolzballs wants to merge 2 commits intoKhronosGroup:mainfrom
lolzballs:mem-align

Conversation

@lolzballs
Copy link
Contributor

@lolzballs lolzballs commented Nov 27, 2025

Description

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.

Type of change

Bug fix

Issue (optional)

Fixes #51.

Tests

AMD Radeon RX 7900 XTX (RADV NAVI31) / radv Mesa 25.3.5-arch1.1 / Arch Linux

Total Tests: 70
Passed: 51
Crashed: 0
Failed: 0
Not Supported: 1
Skipped: 18 (in skip list) -- Improved from 26 previously
Success Rate: 100.0%

Additional Details (optional)

@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.

@dabrain34
Copy link
Contributor

@lolzballs can you rebase on main to run the testing framework on it ? @zlatinski anything to add or is it good for you to go ?

@lolzballs lolzballs force-pushed the mem-align branch 3 times, most recently from 0239609 to 02371b6 Compare January 29, 2026 14:53
@dabrain34
Copy link
Contributor

@lolzballs Can you rebase your commit and update the bug description acccording to the guideline ?

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.
These tests work now with the previous fix.
@dabrain34 dabrain34 changed the title Remove assert for memory alignment common: remove assert for memory alignment Feb 11, 2026
@lolzballs
Copy link
Contributor Author

@zlatinski Could you please review my comment (#120 (comment))?

I don't think nvpro-samples/vk_video_samples@981834c is "more complete", and I prefer not to port that here as it allocates more than necessary.

@dabrain34
Copy link
Contributor

@srinathkr-nv do you think you give it a look and give your feedback ?

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