simd provides types and functions for small vector and matrix computations.

Posts under simd tag

3 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Issue storing SIMD3 (and other simd’s) in a SwiftData model
I'm encountering an issue when trying to store a SIMD3<Float> in a SwiftData model. Since SIMD3<Float> already conforms to Codable, I expected it to work. However, attempting to store a single SIMD3<Float> crashes with the following error: Fatal error: Unexpected property within Persisted Struct/Enum: Builtin.Vec4xFPIEEE32 Interestingly, storing an array of vectors, [SIMD3<Float>], works perfectly fine. The issue only arises when trying to store a single SIMD3<Float>. I’m not looking for a workaround (I can break the vector into individual floats in a custom codable struct to get by) , but I’d like to understand why storing a codable SIMD3<Float> in SwiftData results in this crash. Is this a limitation of SwiftData, or is there something I’m missing about how vectors are handled? Any insights would be greatly appreciated!
3
1
727
Sep ’24
Invert a 3x3 matrix in a Metal compute kernel
I searched the Metal Shading Language Specification Version 3.0 document, however I cannot see any function for inverting a matrix. Is there really no function in Metal for inverting a matrix? I often need to this in linear equations and have so far resorted to writing the necessary function each time, most of the time just copy-and-pasting code. inverse exists in SIMD and GLSL, so why not in Metal? It seems so unexpected that this function does not exist that I am almost certain I have just overlooked something obvious. I even tried 1 / M, to no avail.
2
1
1.8k
Feb ’25