Skip to content
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

vkGetBufferMemoryRequirements reports wrong buffer alignment when running in the iOS simulator #1250

Closed
georged-youi opened this issue Feb 10, 2021 · 1 comment
Assignees
Labels
Bug Completed Issue has been fixed, or enhancement implemented.

Comments

@georged-youi
Copy link

georged-youi commented Feb 10, 2021

When running a Metal app in the iOS simulator, Apple requires that align constant buffer offsets for render commands to be 256 bytes. (see: https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator?language=objc)

Trying to allocate a uniform buffer, vkGetBufferMemoryRequirements returns the alignment as 64 bytes. This leads to the following assert from the metal API validation: validateFunctionArguments:3722: failed assertion 'Fragment Function(main0): the offset into the buffer _23 that is bound at buffer index 0 must be a multiple of 256 but was set to 24960.'

The issue seems to be coming from this file: https://github.com/KhronosGroup/MoltenVK/blob/05066429e29cb5bf11d21cb2bc2b5ebfff94e7ae/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm where mtlBufferAlignment is set to 256 only for MVK_MACOS, but there's no check for the iOS simulator.

@billhollings
Copy link
Contributor

Thanks for reporting this.

Simulator on arm64 macOS will probably be okay, but X86_64 needs to be adjusted.

georged-youi pushed a commit to georged-youi/VulkanMemoryAllocator that referenced this issue Feb 10, 2021
When running in the iOS simulator, constant buffer offsets must be
aligned to 256 bytes. `vkGetBufferMemoryRequirements` is reporting the
wrong alignement in this case. see: KhronosGroup/MoltenVK#1250
@billhollings billhollings self-assigned this Feb 10, 2021
georged-youi pushed a commit to georged-youi/VulkanMemoryAllocator that referenced this issue Feb 10, 2021
When running in the iOS/tvOS simulator, constant buffer offsets must be
aligned to 256 bytes. `vkGetBufferMemoryRequirements` is reporting the
wrong alignement in this case. see: KhronosGroup/MoltenVK#1250
georged-youi pushed a commit to YOU-i-Labs/VulkanMemoryAllocator that referenced this issue Feb 10, 2021
When running in the iOS/tvOS simulator, constant buffer offsets must be
aligned to 256 bytes. `vkGetBufferMemoryRequirements` is reporting the
wrong alignement in this case. see: KhronosGroup/MoltenVK#1250
@billhollings billhollings added the Completed Issue has been fixed, or enhancement implemented. label Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Completed Issue has been fixed, or enhancement implemented.
Projects
None yet
Development

No branches or pull requests

2 participants