`Texture`: Check compatibility of `pixelFormat` and `pixelDataFormat`
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
The `Texture` constructor should check if the combination of `options.pixelFormat` and `options.pixelDataFormat` are allowed in the current WebGL context.
WebGL2 sets new limitations on allowed values of `options.pixelFormat` and `options.pixelDataFormat` in [texImage2D](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D). See the [table of allowed combinations in the spec](https://registry.khronos.org/webgl/specs/latest/2.0/#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE). Note that the combination of `PixelFormat.LUMINANCE` and `PixelDatatype.FLOAT`, while allowed in WebGL1, is no longer allowed in WebGL2.
`Texture` is a private class, but the `pixelFormat` and `pixelDataFormat` options are exposed via `TextureUniform` (for custom shaders) and `PostProcessStage`. Adding a check in `Texture` will prevent problems in both of those public APIs.
The documentation in both `TextureUniform` and `PostProcessStage` should point users to the table of allowed combinations.
Contributor guide
Research direction
Start in the Texture constructor and inspect how TextureUniform and PostProcessStage expose pixelFormat and pixelDataFormat. Compare the validation needed with the linked texImage2D documentation and WebGL 2.0 allowed-combinations table. Done means incompatible combinations are rejected for the current WebGL context and both public API documents point users to the table.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100