From f30c253b7356e853c6c65b897c62dd84ee369ac5 Mon Sep 17 00:00:00 2001 From: Kelsey Gilbert Date: Tue, 17 Feb 2026 13:38:36 -0800 Subject: [PATCH] Fix and clarify language around drawingBufferStorage and RGB8/RGBA8. Two functional changes here: 1. Allow RGB8 for drawingBufferStorage, because it's a normal value for drawingBufferFormat. 2. As such, add RGB8 to WebGL1RenderingContext. But also: Clarify that this doesn't mean you can use it for e.g. texImage2D. Fixes #3669. --- specs/latest/1.0/index.html | 32 ++++++++++++++++++++++---------- specs/latest/1.0/webgl.idl | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/specs/latest/1.0/index.html b/specs/latest/1.0/index.html index 6b126584f..7133e0bdc 100644 --- a/specs/latest/1.0/index.html +++ b/specs/latest/1.0/index.html @@ -395,35 +395,38 @@

The Drawing Buffer

undefined drawingBufferStorage(GLenum sizedFormat, unsigned long width, unsigned long height);
+

Respecify the format and size of the drawing buffer, similar to renderbufferStorage as used on Renderbuffers. - + (However, neither RGB8 nor RGBA8 are valid for renderbufferStorage in unextended WebGL 1.0) +

Clearing behavior is equivalent to setting HTMLCanvasElement.width and HTMLCanvasElement.height, followed by changing the drawing buffer format. This method respects WebGLContextAttributes.antialias. - +

drawingBufferStorage allows for efficiently respecifying width and height together simultaneously. With HTMLCanvasElement.width and HTMLCanvasElement.height, setting one and then the other can incur intermediate reallocations, though User Agents do try to optimize these out.
- +

If drawingBufferStorage is successful, the drawingBufferFormat becomes sizedFormat. drawingBufferWidth and drawingBufferHeight become width and height respectively. Operations on the default framebuffer therefore behave as if operating on a non-default framebuffer with an attachment of sizedFormat. E.g. after drawingBufferStorage(gl.RGBA16F, 1, 1), because the framebuffer is "floatish", readPixels's main format/type pair is RGBA/FLOAT instead of RGBA/UNSIGNED_BYTE. - +

If WebGLContextAttributes.alpha is false, generate INVALID_OPERATION. - - RGBA8 is always supported for sizedFormat. +

+ RGB8 and RGBA8 are always supported for sizedFormat. +

Additionally, the following enums are supported if they are currently valid for renderbufferStorage:

    -
  • RGBA8
  • SRGB8_ALPHA8 (0x8C43) (E.g. from EXT_sRGB)
  • RGBA16F (0x881A) (E.g. from EXT_color_buffer_half_float)
+

If sizedFormat is not currently supported, generate INVALID_ENUM. - +

In WebGL 1.0, SRGB8_ALPHA8 requires the extension EXT_sRGB. @@ -434,11 +437,12 @@

The Drawing Buffer

In WebGL 2.0, RGBA16F requires the extension EXT_color_buffer_float.

- +

If width or height are greater than the limit MAX_RENDERBUFFER_SIZE, generate INVALID_VALUE. - +

If allocation fails, generate OUT_OF_MEMORY. +

@@ -1743,6 +1747,7 @@

The WebGL context

const GLenum RGBA4 = 0x8056; const GLenum RGB5_A1 = 0x8057; + const GLenum RGB8 = 0x8051; const GLenum RGBA8 = 0x8058; const GLenum RGB565 = 0x8D62; const GLenum DEPTH_COMPONENT16 = 0x81A5; @@ -2777,6 +2782,13 @@

Texture objects

Uploads the given element or image data to the currently bound WebGLTexture.

+
+ Sized internal formats are invalid for texture specification in WebGL 1.0. + Therefore even though drawingbufferStorage uses RGBA8, + texImage2D must use RGBA instead. + (Same with RGB8 and RGB) +
+ The width and height of the texture are set as specified in section Texture Upload Width and Height.

diff --git a/specs/latest/1.0/webgl.idl b/specs/latest/1.0/webgl.idl index fb976550e..57e937657 100644 --- a/specs/latest/1.0/webgl.idl +++ b/specs/latest/1.0/webgl.idl @@ -490,6 +490,7 @@ interface mixin WebGLRenderingContextBase const GLenum RGBA4 = 0x8056; const GLenum RGB5_A1 = 0x8057; + const GLenum RGB8 = 0x8051; const GLenum RGBA8 = 0x8058; const GLenum RGB565 = 0x8D62; const GLenum DEPTH_COMPONENT16 = 0x81A5;