3 ms·
I have been using GPU.js in the last few weeks and I feel like there are two parts to the magic that makes it work. The headline feature is the translation of
by Lerc 5y ago
I have been using GPU.js in the last few weeks and I feel like there are two parts to the magic that makes it work.
The headline feature is the translation of JavaScript into Shader code, but the underlying architecture that interfaces between arrays and textures is I think where the utility really comes in for me.
I think I'd actually be better off working with just that second part. Writing the kernels in a more native shader language but being able to pass in arrays and get arrays out the other end.
While the aspect of writing the shader itself in JavaScript is cool when you consider what it has to do to make it work, when it doesn't work it can be a real struggle to find out why.
Also there seems to be a bit of bit-rot in the documentation the link for the API reference is https://doxdox.org/gpujs/gpu.js/ https://doxdox.org/gpujs/gpu.js/
- phist_mcgee 5y ago>when it doesn't work it can be a real struggle to find out why. Exactly like most GPGPU debugging then!
- Agentlien 5y agoI mainly work with graphics programming and while it can be a bit opaque I feel that this is nowhere near the problem it was just ten years ago. Modern graphics debuggers such as RenderDoc give an amazing view of what is going on and on consoles (using nSight, PIX or Razor GPU) you can also debug things by connecting a replay, modifying shaders on the fly, etc. Having originally learned graphics programming before such tools existed I really can't get over how magic this feels.
- tppiotrowski 5y agoI've also used this for a few months. Here's some things that might bite you: - Minification: The JS code is transpiled at runtime and there's some subtle errors that can occur once you minify your code - Performance: Each time you pass a JS array into GPU land, it's copying the data into a texture. If you want to do repeated calculations on the same data you should not be passing the arrays in each time because CPU/GPU data transfer will become a performance bottleneck. - Math.atan2: the implementation is incorrect and I burned a few days because of it. I PR'ed the fix a few months ago but the library maintainer no longer seems active. It's an awesome library. I write mostly GLSL now, but I still will write the initial algorithm and transpile is using GPU.js and then tweak the output accordingly.