-
Notifications
You must be signed in to change notification settings - Fork 158
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】The DeviceFeatureLimits::BufferAlignment is not always equals 16 byte on Metal backend #114
base: main
Are you sure you want to change the base?
Conversation
@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@vinsentli are you running into this issue while trying to allocate a uniform buffer or a buffer to hold the texture? Please give an example of the usage so we can better assess next steps. |
@vinsentli Could you please share some test code snippet or a usage example showing how exactly this value is being used? |
@syeh1 @corporateshark |
https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object#Data_storage |
This is my use scene: put the data for multiple uniform blocks in a single buffer object. In that scene,must make sure that the data for each within that block matches this alignment. |
Ok, got it. In that case, iOS is 256b, but M2 would be 32b (looking at the Minimum Constant Buffer offset Alignment row) |
On m2 is 32B,means 128byte.@syeh1 |
I update the value on macos. |
@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
I'm trying to review this, but things are very unclear. Let's start by establishing some things:
Now, onto the speculative:
IMO, given the lack of real examples, we should go with this simpler/safer alternative:
Thoughts? |
There is a easy way to verify the alignment value on MacOS。 In the ColorSession demo, modify the bufferOffset value from 0 to 1, the Xcode will report an error. I verify the value on MacOS with arm GPU(Apple M1 Pro), the alignment value is 16 bytes. It aligns with the instructions provided in the documentation. I verify the value on MacOS with Intel GPU(Apple M1 Pro), the alignment value is 32 bytes. Indeed, it has been confusing me. Yes , use 256 bytes on MacOS more safer. @tgoulart @corporateshark #if IGL_PLATFORM_MACOS || IGL_PLATFORM_IOS_SIMULATOR |
The DeviceFeatureLimits::BufferAlignment is not always equals 16 byte on Metal backend.
For example , on iOS simulator is 256.
https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator
When you set arguments for the render or compute command, align constant buffer offsets to 256 bytes.
And I have not test the value on MacOS. Maybe it is same with iOS simulator. I cannot verify it.
From the https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf it shows 256B on M2.