[webkit-changes] [WebKit/WebKit] 939048: [WebXR] Use linear RGBA format for back buffer

Dan Glastonbury noreply at github.com
Mon Feb 12 22:52:07 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9390487621338e7d449be74b6c63078aecb33844
      https://github.com/WebKit/WebKit/commit/9390487621338e7d449be74b6c63078aecb33844
  Author: Dan Glastonbury <djg at apple.com>
  Date:   2024-02-12 (Mon, 12 Feb 2024)

  Changed paths:
    M Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp

  Log Message:
  -----------
  [WebXR] Use linear RGBA format for back buffer
https://bugs.webkit.org/show_bug.cgi?id=269257
rdar://122842875

Reviewed by Mike Wyrzykowski.

Use GL_RBGA8, instead of GL_SRGB8_ALPHA8 for WebXROpaqueFramebuffer color
buffers.

The CSS color spec defines the colorspace of content as sRGB. The sRGB
spec (https://en.wikipedia.org/wiki/SRGB) defines two concepts:
1) The gamut (which is the "color space"), and
2) The "gamma" or "transfer function"

By default, when the browser interprets the content of a canvas, it treats 8-bpp
formats as in the sRGB colorspace encoded with the sRGB gamma transfer function.

In OpenGL and WebGL, the output of fragment shaders are considered to be
"linear", (ie. 0.5 maps to floor(0.5 * 255)). The intention of specifying color
buffers with GL_SRGA8_ALPHA8 was to enable the sRGB transfer function to
fragment outputs, automatically ensuring the color buffer contained sRGB gamma
encoded values.

While automatic transfer from linear to sRGB gamma is the "right thing to do",
this feature is a notoriously buggy and inconsitent in OpenGL
implementations. WebGL doesn't provide an API for controlling the enablement of
the sRGB transfer function, so using GL_SRGB8_ALPHA8 for WebXROpaqueFramebuffer
is the wrong thing to do. This makes the behavior of WebXROpaqueFramebuffer
consistent with standard WebGL color buffers.

* Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:
(WebCore::WebXROpaqueFramebuffer::allocateColorStorage):

Canonical link: https://commits.webkit.org/274526@main




More information about the webkit-changes mailing list