4 ms·
Perfect timing, I was just about to start looking into SIMD again as my toy game engine is almost at a point where I want to see if I can vectorize some of my p
by dkersten 6y ago
Perfect timing, I was just about to start looking into SIMD again as my toy game engine is almost at a point where I want to see if I can vectorize some of my processing (much of it is already stored in SOA format, so hopefully it won't be too much trouble). I'm thinking especially about tasks like frustum culling, but also other things. We'll see, after I read this :) I've used SIMD intrinsics before, but I could definitely do with a refresher!
- Const-me 6y agoFor videogame applications, look there before writing these intrinsics: https://github.com/microsoft/DirectXMath/ https://github.com/microsoft/DirectXMath/ That library already implements a lot of complicated things, relatively well. Here’s for frustum culling https://github.com/microsoft/DirectXMath/blob/jan2021/Inc/DirectXCollision.inl#L3070-L3104 https://github.com/microsoft/DirectXMath/blob/jan2021/Inc/Di... Relatively inefficient when you have many boxes to test against same frustum, but (a) compiler may inline and optimize (b) failing that, it’s easy to copy-paste and optimize manually, compute these 6 planes and call BoundingBox::ContainedBy method yourself.
- dkersten 6y agoThanks, I’ll take a look. Although, it’s a for fun engine so I may try myself anyway just to learn. I’ll see. Either way, thanks for the link, very interesting! As for frustum culling, that code seems to do one bounding box at a time? Or am I misunderstanding? I was planning to try to do 4 (or however many) checks at a time. I’m ok with checking against bounding spheres too if that makes it easier to vectorize.
- Const-me 6y ago> that code seems to do one bounding box at a time? Yep, most parts of that library were designed for doing one thing at a time. Generally speaking, HPC-style SoA approach can be faster especially if you have AVX. But there’s a price for that, most importantly code complexity but some performance-related things as well: RAM access pattern, uploading to VRAM for rendering. > I was planning to try to do 4 (or however many) checks at a time I would start with whatever code is in that library, and only optimize if profiler says so. They have sphere versus frustum test too, similar one i.e. they also testing against these 6 planes, might be slightly more efficient than boxes.
- dkersten 6y agoOk, thank you! Much appreciated.