Skip to content

Better define texture data conversions from non-buffer sources #3737

@lexaknyazev

Description

@lexaknyazev

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. Clarify UNPACK_PREMULTIPLY_ALPHA for floating-point and integer pixel formats #3667

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions