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

Metal buffer alignment is not 256 on iOS arm64 simulator #1989

Closed
LeavesInAutumn opened this issue Aug 8, 2023 · 1 comment
Closed

Metal buffer alignment is not 256 on iOS arm64 simulator #1989

LeavesInAutumn opened this issue Aug 8, 2023 · 1 comment
Labels
Bug Completed Issue has been fixed, or enhancement implemented.

Comments

@LeavesInAutumn
Copy link

Hello, I get the following errors when running my app with MoltenVK on iOS arm64 simulator (Apple M1 chips):

-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:], line 5326: error 'Draw Errors Validation
Vertex Function(VS_Entry_lusion): the offset into the buffer _9 that is bound at buffer index 0 must be a multiple of 256 but was set to 384.
'
-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:], line 5326: error 'Draw Errors Validation
Vertex Function(VS_Entry_lusion): the offset into the buffer _9 that is bound at buffer index 0 must be a multiple of 256 but was set to 262336.
'
-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:], line 5326: error 'Draw Errors Validation
Vertex Function(VS_Entry_lusion): the offset into the buffer _9 that is bound at buffer index 0 must be a multiple of 256 but was set to 262528.
'
-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:], line 5326: error 'Draw Errors Validation
Vertex Function(VS_Entry_lusion): the offset into the buffer _9 that is bound at buffer index 0 must be a multiple of 256 but was set to 192.

I've noticed that someone has encountered this problem: #1250
And MoltenVK Release note 2021/02/22 said:

Set Metal buffer alignment to 256 on non-Apple Silicon iOS/tvOS simulators.

But why Apple Silicon iOS simulators do not use alignment as 256 ?

I guess we should always use alignment as 256 on all simulators according to the Apple official documents: https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator?language=objc

When you set arguments for the render or compute command, align constant buffer offsets to 256 bytes. Normally, iOS requires an alignment of 4 bytes. This difference may mean that you might need to arrange your data differently when running in Simulator.

And if I was wrong, how can I resolve these errors?
Do I need to define any macros to tell MoltenVK the target is arm64 simulator ?

Thanks in advance !

@LeavesInAutumn LeavesInAutumn changed the title Metal buffer alignment Metal buffer alignment is not 256 on Apple M1 chips arm64 simulator Aug 9, 2023
@LeavesInAutumn LeavesInAutumn changed the title Metal buffer alignment is not 256 on Apple M1 chips arm64 simulator Metal buffer alignment is not 256 on iOS arm64 simulator Aug 9, 2023
@billhollings
Copy link
Contributor

PR #1993 fixes this. Please retest with latest MoltenVK and close this issue if the problem is resolved.

@billhollings billhollings added the Completed Issue has been fixed, or enhancement implemented. label Aug 14, 2023
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