-
Notifications
You must be signed in to change notification settings - Fork 38
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
Create MtlArray using memory allocated by Array #320
Conversation
Maybe a check to see if a pointer is page-aligned and throw otherwise? And then for |
In theory the function is already unsafe. Might as well be up to the user to check? Not sure. But yeah either documenting or asserting is a good idea. |
d6ca650
to
5f246ae
Compare
I believe that this code works in MacOS 14.4 but not MacOS 13.x. For some reason, on 14.4, Does anyone have any ideas as to why? |
FWIW, https://developer.apple.com/documentation/metal/mtldevice/1433382-newbufferwithbytesnocopy still mentions that the pointer has to be page-aligned. |
Apparently the array/buffer size also has to be divisible by 4096 to work in MacOS 13. |
817e4d7
to
e545c3a
Compare
ec91439
to
20b6079
Compare
20b6079
to
657c16b
Compare
I think we always have to enforce pointer and buffer alignment:
Even though it seems to work on macOS 14, it does seem to violate the docs. I'll push a commit, if you don't mind. |
GC.@preserve Better? interface Add tests Improve error message
657c16b
to
03278ab
Compare
@christiangnrd I tightened the check as mentioned above, and also simplified the implementation a little: determining |
All the changes you made seem like improvements to me. |
Thanks! |
Feedback on implementation, interface, tests, etc. is welcome.
Closes #62