Graphical option with ImageData doesn't work in WebWorker
- Lingua principale
- JavaScript
- Stelle
- 15.5k
- Fork
- 663
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## Issue
Graphical option with ImageData doesn't work in WebWorker but when I use `{mode: 'cpu'}` it works.
## Env
Google Chrome
FireFox
Windows 11 22H2
i7 8565U
UHD Graphics 620
Windows 11 22H2
i7 1255U
Intel Iris Xe Graphics
## Code
```javascript
// doesn't work
const gpu = new GPU();
const graphicalTest = gpu.createKernel(function(data) {
const [r, g, b, a] = data[this.thread.y][this.thread.x];
this.color(r, g, b, a);
}, {
output: [width, height],
graphical: true,
});
graphicalTest(imageData/* ImageData Object */);
const newImageData = new ImageData(Uint8ClampedArray.from(graphicalTest.getPixels()), this.#width, this.#height);
// > gpu-browser.min.js:28 Uncaught (in promise) Error: Error compiling fragment shader: ERROR: 0:465: 'color' : no matching overloaded function found
// works
const gpu = new GPU({mode: 'cpu'});
const graphicalTest = gpu.createKernel(function(data) {
const [r, g, b, a] = data[this.thread.y][this.thread.x];
this.color(r, g, b, a);
}, {
output: [width, height],
graphical: true,
});
graphicalTest(imageData/* ImageData Object */);
const newImageData = new ImageData(Uint8ClampedArray.from(graphicalTest.getPixels()), this.#width, this.#height);
// doesn't work
const gpu = new GPU();
const graphicalTest = gpu.createKernel(function(data) {
const [r, g, b, a] = data[this.thread.y][this.thread.x];
const sum = r + g + b + a;
this.color(r, g, b, a);
}, {
output: [width, height],
graphical: true,
});
graphicalTest(imageData/* ImageData Object */);
const newImageData = new ImageData(Uint8ClampedArray.from(graphicalTest.getPixels()), this.#width, this.#height);
// > Uncaught (in promise) Error: Unhandled binary expression between Number & Array(4) on line 2, position 3:]
// works
const gpu = new GPU({mode: 'cpu'});
const graphicalTest = gpu.createKernel(function(data) {
const [r, g, b, a] = data[this.thread.y][this.thread.x];
const sum = r + g + b + a;
this.color(r, g, b, a);
}, {
output: [width, height],
graphical: true,
});
graphicalTest(imageData/* ImageData Object */);
const newImageData = new ImageData(Uint8ClampedArray.from(graphicalTest.getPixels()), this.#width, this.#height);
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Non vengono indicati file o test del repository. Inizia riproducendo l'esempio createKernel fornito con ImageData in un WebWorker su Chrome o Firefox, quindi traccia la compilazione dello shader grafico e la gestione dell'input. Il lavoro è completato quando la modalità grafica accetta l'input ImageData in un WebWorker senza gli errori di shader o di espressione binaria segnalati, mentre la modalità CPU continua a funzionare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- computer-graphics
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100