So, a couple of days ago, I was feelin' pretty suave getting the ray tracing going in pure Swifty goodness. But I could not resist the allure of the GPU. I decided to stalk the illusive beast known as Metal. And that's kinda what it felt like. I did not jump right in and start coding it up, since I have but a modest idea what's going on in Metal, apart from aping Apple's example code, and transliterating some OpenCL code, earlier in the year. For me the troubles were about how to paint on a texture and to understand the ins and outs of the Metal Shading Language.
For those just wanting to know if it was worth it: The same 1600x800 scene and over 480 reflective objects, went from 702 seconds in the pure Swift version down to 14 seconds! Roughly a 50x speed improvement. That is racing a 12-core Xeon with hyperthreading against a D700 graphics card. Well worth the time invested to compare.
[Read more…]