github gpujs/gpu.js 2.24.1

5 hours ago

Kernels that subtract a negated value — a - -bnow compile on every backend instead of failing with a shader syntax error. No breaking changes.

a - -b no longer compiles to a decrement

A negated operand was emitted with nothing between its minus sign and the one before it, so a - -b came out as a--b. GLSL, WGSL and JavaScript all read -- as the decrement operator, and the kernel failed to build: a syntax error on the webgl, webgl2 and headless-gl backends, a WGSL parse error on webgpu, and invalid generated JavaScript on cpu. Only webasm, which has its own code generator, was unaffected.

Hand-written kernels rarely contain a - -b, but minified ones do all the time: minifiers rewrite a + 0.95 as a - -0.95. That is how it surfaced in #874, where a minified path-tracing kernel failed on webgpu with expected ')', found "--".

Negated operands are now parenthesized, so the example emits (a-(-b)). On webgpu, negative constants are written into the shader in parentheses too, since a - this.constants.c with a negative c hit the same error.

Installing

npm install gpu.js@2.24.1
<script src="https://unpkg.com/gpu.js@2.24.1/dist/gpu-browser.min.js"></script>

Don't miss a new gpu.js release

NewReleases is sending notifications on new releases.