Open TomWyllie opened 4 years ago
This is probably due to the ESSL specifying that the max
and min
functions can only take two variables. See page 66 of the spec. Perhaps when parsing the kernel code GPU.js could automatically expand Math.max(x, y, z)
to Math.max(Math.max(x, y), z);
or similar? I spent quite a bit of time debugging this reckoning it was the types of my variables that were wrong rather than that only two parameters were supported...
What is wrong?
Using
Math.max
with more than two parameters causes the GPU kernel build to fail.How do we replicate the issue?
And observe the output error
gpu-browser.js:14913 Uncaught Error: Error compiling fragment shader: ERROR: 0:457: 'max' : no matching overloaded function found
. Replacing0, 1, 2
with0, 1
(or any other two numbers) leads to the function behaving as expected. The same is true ofMath.min
. JS Fiddle: https://jsfiddle.net/TomWyllie/opdg95kb/GPU.js 2.9.4 GPU: NVIDIA GeForce GTX 1060 3GB Nvidia Driver 446.14 Google Chrome Version 83.0.4103.97 (Official Build) (64-bit) Windows 10
How important is this (1-5)?
2, it's very easy (but pretty messy) to workaround by using
Math.max(x, Math.max(y, Math.max(z, t)));
or similar, but that is pretty ugly. My understanding is that the spec allows arbitrarily many parameters.Other Comments
I'm beginning to think there might be something deeper wrong with GPU.js on my machine given this issue and the other I filed several days ago (#617) must be very common use cases and surely lots of other people would be having these same problems... any thoughts appreciated.