Re:WebAssembly Raytracer
by zurn on Saturday December 16, 2017 @07:21AM
(#15939233)
Interesting that there is a 1000x speed difference (0.1 vs 100 ms, in Chrome) between the shader and the JS/WebASM versions even with just Intel integrated graphics.
[ Parent
| on HN ]
Even after working with them for a while, GPUs still feel like cheating. They are just so goddamn good at what they do.
That kind of speed up isn't just a fluke here, it's pretty normal when your work aligns with what a GPU does best.
Re:WebAssembly Raytracer
by roywiggins on Saturday December 16, 2017 @05:27PM
(#15942567)
They're really fast even if you're sort of abusing them. Using fragment shaders to render entire scenes ("two triangle" style) probably wasn't what GPUs were built to do but the technique is awfully effective.
I've been working with GPUs for many years now and I still get surprised by their performance: some things turn out to be so bloody fast that I initially think that i must do something wrong. Other times, CPU implementations run circles around the GPU for no obvious reason. It's not intuitive and I still have a hard time wrapping my head around how fast these things are when they are at their best.
It is a complete different way of working, but sometimes it just feels like going back to Amiga coding with Blitter and DMA.
It was would interesting to compare a C or Assembly version against a shader version. My hunch is that this is just a use case where a general purpose CPU is left in the dust by a modern GPU.
A shader is just taking advantage of the GPU parallelism. Would still wreck C++ implementation.
Re:WebAssembly Raytracer
by singularity2001 on Saturday December 16, 2017 @09:53AM
(#15939761)
the emscripten.cpp is pretty much c?
Re:WebAssembly Raytracer
by singularity2001 on Saturday December 16, 2017 @10:21AM
(#15939893)
oh you mean outside of the browser. yes that would be interesting
Yep. That's what I meant.
The GPU version is much faster, but I doubt it's that much. I suspect the actual rendering time is not being measured because it happens asynchronously.
Still though, the potential for using GPUs to accelerate computations is high and I think too often overlooked by web developers, even those doing image processing.