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

Textures - read and write #801

Open
lukeellison opened this issue Nov 30, 2022 · 2 comments
Open

Textures - read and write #801

lukeellison opened this issue Nov 30, 2022 · 2 comments

Comments

@lukeellison
Copy link

lukeellison commented Nov 30, 2022

A GIF or MEME to give some spice of the internet

What is wrong?

Assignment to a texture fails with error gpu-browser.min.js:28 Uncaught Error: Error compiling fragment shader: ERROR: 0:461: 'assign' : l-value required. This should be possible but may not be implemented and would be useful. Regardless the error is cryptic.

Where does it happen?

In Web2GL supported browser running on a mac.

How do we replicate the issue?

const clearKernel = gpu
  .createKernel(function () {
    return 0;
  })
  .setOutput([3, 3])
  .setPipeline(true)
  .setImmutable(true);

const testKernel = gpu
  .createKernel(function (_tex) {
    const x = this.thread.x;
    _tex[x][x] = 1;
    return 0;
  })
  .setOutput([2]);

const tex = clearKernel();
const result = testKernel(tex);
console.log(tex.toArray());
tex.delete();

How important is this (1-5)?

I would say 2 because it currently doesn't break anything but the error and lack of claims that this is not supported is confusing. If it is supposed to be supported it should be higher.

Expected behavior (i.e. solution)

Should not error and should show:

[[1,0,0],
 [0,1,0],
 [0,0,0]]

Other Comments

Another solution would be to have some way of outputting a copied texture that was a different size to the kernel size? I.e different output size to kernel size.

Thank you for your time looking into this.

@regretronics
Copy link

i got the same problem even when the textures are not immutable. that feature would be really useful to me, because i'm doing deeply iterative computations (currently, creating new textures for every iteration, which sometimes causes freezing or unpredictable jittering).

@SparkHao
Copy link

The array passed as a parameter cannot be modified internally, I don't know why

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

3 participants