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

setImageData 报错 #102

Closed
xiaoiver opened this issue Dec 8, 2023 · 3 comments
Closed

setImageData 报错 #102

xiaoiver opened this issue Dec 8, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented Dec 8, 2023

antvis/L7#2128 (comment)

报错信息如下:

[.WebGL-0x128004f3f00] GL_INVALID_OPERATION: Invalid internal format 0x1909.
@xiaoiver xiaoiver self-assigned this Dec 8, 2023
@xiaoiver xiaoiver added the bug Something isn't working label Dec 8, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Title: setImageData error report

@xiaoiver
Copy link
Contributor Author

xiaoiver commented Dec 12, 2023

另外 LUMINANCE 并不是可读的,无法使用 readPixels 读取数据
https://webgl2fundamentals.org/webgl/lessons/webgl-readpixels.html

正确用法如下:
https://webglfundamentals.org/webgl/lessons/webgl-data-textures.html

const dataTexture = device.createTexture({
  format: Format.U8_LUMINANCE,
  width: 1,
  height: 1,
  usage: TextureUsage.SAMPLED,
  pixelStore: {
    unpackFlipY: false,
    packAlignment: 1, // deal with 1 byte at a time
  },
  mipLevelCount: 0, // don't mipmap
});

xiaoiver added a commit that referenced this issue Dec 12, 2023
* fix: split Format.ALPHA and LUMINANCE #102

* chore: commit changeset
xiaoiver added a commit that referenced this issue Dec 12, 2023
* Fix 102 (#103)

* fix: split Format.ALPHA and LUMINANCE #102

* chore: commit changeset

* chore(release): bump version (#104)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@xiaoiver
Copy link
Contributor Author

xiaoiver commented Dec 13, 2023

如下代码在 WebGL2 下报错:

const floatRGB = device.createTexture({
  format: Format.F32_RGB,
  width: 1,
  height: 1,
  usage: TextureUsage.SAMPLED,
});
floatRGB.setImageData([new Float32Array([10, 20, 30])]);
[.WebGL-0x1180050e300] GL_INVALID_OPERATION: Invalid internal format 0x1907.

原因是 WebGL2 中 internal format 可以与 format 不同,对应关系如下:
https://webgl2fundamentals.org/webgl/lessons/webgl-data-textures.html

例如这里 internal format 应该是 gl.RGB32F,format 为 gl.RGB

xiaoiver added a commit that referenced this issue Dec 13, 2023
* fix: use internal format in webgl2 #102

* chore: commit changeset
xiaoiver added a commit that referenced this issue Dec 13, 2023
* Fix 102 (#106)

* fix: use internal format in webgl2 #102

* chore: commit changeset

* chore(release): bump version (#107)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants