Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical option with ImageData doesn't work in WebWorker #812

Open
T-Ndev opened this issue Feb 7, 2023 · 0 comments
Open

Graphical option with ImageData doesn't work in WebWorker #812

T-Ndev opened this issue Feb 7, 2023 · 0 comments

Comments

@T-Ndev
Copy link

T-Ndev commented Feb 7, 2023

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

// 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant