KhronosGroup / KhronosGroup/WebGL

Better define texture data conversions from non-buffer sources

Open
#3,737 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
2.9k
Forks
703
Avg merge
2d 9h
Merged PRs (30d)
4

Description

The WebGL spec defines `TexImageSource` as follows:
```
typedef (ImageBitmap or
ImageData or
HTMLImageElement or
HTMLCanvasElement or
HTMLVideoElement or
OffscreenCanvas or
VideoFrame) TexImageSource;
```

The exact process of converting source pixel values to the target texture format is not fully defined. This issue lists several previously-identified areas that should be clarified.

1. Color space conversions:
- Assuming that `UNPACK_COLORSPACE_CONVERSION_WEBGL` is set to `BROWSER_DEFAULT_WEBGL`, are there any guarantees that when the image's detected color space and the context's `unpackColorSpace` parameter match, there would be no conversion?
- Should implementations issue console warnings when the color space conversion narrows the range, thus likely clamps the original values (e.g., a P3 image uploaded with `unpackColorSpace` set to sRGB)?
- There should be tests for colorspace conversions from Canvas sources.
2. Bit depth conversions. When the number of bits per channel does not match between the source image and the target GPU format, how exactly the conversion is performed? The spec has a few relevant statements but they do not cover all cases. In particular:
- Handling of `RGB10_A2` (original values are likely rescaled to target precision)
- Handling of `*UI` formats for less-than-8-bit sources (e.g., 1/2/4-bit PNG)
- Handling of images with more than 8 bits per channel, e.g., 16-bit PNG, uploaded to GPU formats with fewer bits
3. #3667

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the WebGL specification sections covering TexImageSource, color-space conversion, and bit-depth conversion, along with the related discussion in issue #3667. Define the missing conversion rules and identify the required Canvas color-space tests; done means the specification covers the listed source and target-format cases and the tests exercise the clarified behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
computer-graphics, web-dev
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.