Zig Structs of Arrays (2024)
103 points - last Thursday at 6:28 AM
SourceComments
smallstepforman today at 1:19 PM
The GPU loves arrays of structures AoS, since all vertex data fits in its triangle assembly cache. Once given to the GPU, the software side doesnt really care for all vertex parameters so this optimisation is pointless. Only relavent when you have instance rendering (leaves, grass) but then you only need an array of vec3’s, not the other parameters so back to normal arrays.
Meanwhile, game engines need operator overloading for adding/multiplying vectors (spatial transforms, lighting, physics) and core zig design philosophy prevents operator overloading.
Blind leading the blind. Disclaimer - I do professional rendering engines.
Sweepi today at 11:26 AM
OT: I just spend a few minutes searching for the source of the "Not all CPU operations are created equal" slide of the linked presentation (Andrew Kelley - Practical DOD), its here:
https://6it.dev/blog/infographics-operation-costs-in-cpu-clo...
hiccuphippo today at 12:55 PM
Hugged to death. Mirror: https://web.archive.org/web/20260608113005/https://andreasho...
trymas today at 12:26 PM
Slightly related recent HN post: https://news.ycombinator.com/item?id=48382382
binaryturtle today at 12:56 PM
I'm just seeing a "410 Gone" error on the linked site (same happens to the parent URL too).
Thaxll today at 12:47 PM
This is what games do with ECS.
nejam today at 2:26 PM
Jfpe?
nejam today at 2:16 PM
Jdoemhoe