samuelmarina / is-even

Is a number even?
1.85k stars 191 forks source link

GPU support so it can be run in a farm of RTX 4090s? #259

Open jax21es opened 1 year ago

andyman1222 commented 1 year ago

Unfortunately GLSL doesn't support JavaScript strings and as such a 1:1 implementation is impossible. However you can achieve the same result by simply passing "0" or "1" as uniform variables into shader code, effectively enabling GPU support but just doing the bulk work on the CPU like most graphics applications do anyways.

Or alternatively, implement the logic itself into a vertex shader (unless you want to interpolate the truthfulness of a number being even over multiple fragments, then the fragment shader will do), but you will likely run into memory limitations because GPUs have limited room to store compiled shader code. I suggest in this case looking into about 100 individual render buffers to accomplish this task for numbers up to about 10^10 or however high this repo goes.