Graphical output canvas is affected by a separate kernel
- Langage dominant
- JavaScript
- Étoiles
- 15.5k
- Forks
- 663
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description

## *What* is wrong?
It seems as if one kernel's output size can affect the size of a canvas created by another. This means that the canvas created by a kernel is larger than should be expected.
## *Where* does it happen?
GPU.js running in browser in Chrome on a Mac (WebGL2 enabled)
## *How* do we replicate the issue?
```javascript
const gpu = new GPU();
const img_width = 64;
const img_height = 64;
const imgKernel = gpu
.createKernel(function (_image) {
const pixel = _image[this.thread.y][this.thread.x];
return pixel[0];
})
.setOutput([img_width, img_height]);
const renderKernel = gpu
.createKernel(function () {
this.color(1, 0, 0, 1);
})
.setGraphical(true)
.setOutput([32, 32]);
const image = document.createElement("img");
image.src = "./test.png";
image.onload = () => {
console.log("image width x height", image.naturalWidth, image.naturalHeight);
const imgOut = imgKernel(image); // This is not used just run
document.body.appendChild(renderKernel.canvas);
renderKernel();
};
```
The output looks like this:

You can see that the canvas is 64x64 pixels, the size of the `imgKernel` but the red section is 32x32 inside that which is the output of `renderKernel` despite the two having no relationship other than both of them are called.
## *How* important is this (1-5)?
*5* This is a pretty limiting bug if you want to use multiple kernels.
## Expected behavior (i.e. solution)
Should show a 32x32 red canvas as far as I can tell.
## Other Comments
Thank you for your time looking at this.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par exécuter dans Chrome la reproduction fournie de GPU.js dans le navigateur avec WebGL2 activé, en vous concentrant sur createKernel, setGraphical, setOutput et l’interaction avec renderKernel.canvas. Comparez les dimensions du canvas après l’exécution de imgKernel avec la sortie graphique attendue de 32x32. C’est terminé lorsque le kernel d’image séparé n’affecte plus la taille du canvas rendu, qui devrait être de 32x32 et entièrement rempli par la sortie rouge.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- computer-graphics
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100