
Show HN: RTX Real-Time Ray Tracing in JavaScript - Schampu
https://github.com/maierfelix/nvk-examples#rtx
======
thethirdone
I was under the impression that the main benefit of Vulcan was reduced CPU
overhead and allow multithreading for GPU related code.

It seems like pairing it with node negates most of that advantage. Is that an
accurate assumption?

If it is, why use a vulkan api rather than an OpenGL or WebGL api?

~~~
Schampu
Vulkan has a very verbose setup phase, but after that you only make some tiny
calls here and there (Draw a frame, update some UBOs), so the CPU load isn't
that high because you record most things at start-up.

Multi-threading is possible with SharedArrayBuffers [0] and N-API allows to
take the memory address of it. NVK is only a thin layer above Vulkan and
JavaScript <-> C++ interopability is pretty fast. You only notice some
overhead when making thousands of calls, because the C++ code cannot be
inlined. But again, this is not something common in Vulkan.

Also JavaScript doesn't have essential features like Compute shaders for years
now. Vulkan has all of it. Even though WebGPU [1] is in development, I don't
expect it to give access to the Vulkan RTX pipeline anytime soon.

[0] SharedArrayBuffer:
[https://v8docs.nodesource.com/node-4.8/d4/db8/classv8_1_1_sh...](https://v8docs.nodesource.com/node-4.8/d4/db8/classv8_1_1_shared_array_buffer.html)

[1] WebGPU:
[https://github.com/gpuweb/gpuweb](https://github.com/gpuweb/gpuweb)

