Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Math.max and Math.min only accept two parameters

Aperta
#618 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript

Direzione di ricerca

Inizia riproducendo l’esempio di kernel GPU.js fornito con Math.max e Math.min usando tre o più argomenti, quindi esamina come queste chiamate vengono tradotte nello shader GPU. Il lavoro è completato quando le chiamate con più argomenti vengono compilate e restituiscono il risultato previsto senza richiedere workaround annidati; verifica l’esempio originale e il caso con due argomenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A GIF or MEME to give some spice of the internet

What is wrong?

Using Math.max with more than two parameters causes the GPU kernel build to fail.

How do we replicate the issue?

const gpu = new GPU({ mode: 'gpu' });
const kernel = gpu.createKernel(function() {
    return Math.max(0, 1, 2);
}).setOutput([1]);
kernel();

And observe the output error
gpu-browser.js:14913 Uncaught Error: Error compiling fragment shader: ERROR: 0:457: 'max' : no matching overloaded function found. Replacing 0, 1, 2 with 0, 1 (or any other two numbers) leads to the function behaving as expected. The same is true of Math.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.

Lingua principale
JavaScript
Stelle
15.5k
Fork
663
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di gpujs/gpu.js

Tutte le issue di gpujs/gpu.js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.