Skip to content

Commit

Permalink
Spec glrc.backbufferStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
kdashg committed Mar 4, 2021
1 parent 08c57bd commit 8b7b88a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
51 changes: 51 additions & 0 deletions specs/latest/1.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,54 @@ <h3><a name="THE_DRAWING_BUFFER">The Drawing Buffer</a></h3>
</p>
</div>

<dl class="methods">
<dt class="idl-code">undefined backbufferStorage(GLenum sizedFormat, unsigned long width, unsigned long height);
<dd>
Respecify the size and format of the backbuffer,
similar to <code>renderbufferStorage</code> as used on Renderbuffers.

Clearing behavior is equivalent to setting <code>HTMLCanvasElement.width</code> and <code>HTMLCanvasElement.height</code>, followed by changing the backbuffer format.
This method respects <code>WebGLContextAttributes.antialias</code>.

<div class="note">
<code>backbufferStorage</code> allows for efficiently respecifying width and height together simultaneously.
With <code>HTMLCanvasElement.width</code> and <code>HTMLCanvasElement.height</code>,
setting one and then the other can incur intermediate reallocations, though User Agents do try to optimize these out.
</div>

If <code>backbufferStorage</code> is successful, the default framebuffer's effective internal format becomes <code>sizedFormat</code>.
Operations on the default framebuffer therefore behave as if operating on a non-default framebuffer with an attachment of <code>sizedFormat</code>.
E.g. after <code>backbufferStorage(gl.RGBA16F, 1, 1)</code>, because the framebuffer is "floatish",
readPixels's main format/type pair is <code>RGBA</code>/<code>FLOAT</code> instead of <code>RGBA</code>/<code>UNSIGNED_BYTE</code>.

If <code>WebGLContextAttributes.alpha</code> is <code>false</code>, generate <code>INVALID_OPERATION</code>.

<code>RGBA8</code> is always supported for <code>sizedFormat</code>.
Additionally, the following enums are supported if they are currently valid for <code>renderbufferStorage</code>:
<ul>
<li><code>RGBA8</code>
<li><code>SRGB8_ALPHA8</code> (<code>0x8C43</code>) (E.g. from EXT_sRGB)
<li><code>RGBA16F</code> (<code>0x881A</code>) (E.g. from EXT_color_buffer_half_float)
</ul>
If <code>sizedFormat</code> is not currently supported, generate <code>INVALID_ENUM</code>.

<div class="note">
<p>
In WebGL 1.0, <code>SRGB8_ALPHA8</code> requires the extension <code>EXT_sRGB<code>.
In WebGL 2.0, <code>SRGB8_ALPHA8</code> does not require an extension.
</p>
<p>
In WebGL 1.0, <code>RGBA16F</code> requires the extension <code>EXT_color_buffer_half_float<code>.
In WebGL 2.0, <code>RGBA16F</code> requires the extension <code>EXT_color_buffer_float<code>.
</p>
</div>

If <code>width</code> or <code>height</code> are greater than the limit <code>MAX_RENDERBUFFER_SIZE</code>,
generate <code>INVALID_VALUE</code>.

If allocation fails, generate <code>OUT_OF_MEMORY</code>.
</dl>

<!-- ======================================================================================================= -->

<h3><a name="WEBGL_VIEWPORT">The WebGL Viewport</a></h3>
Expand Down Expand Up @@ -1671,6 +1719,7 @@ <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>

const GLenum RGBA4 = 0x8056;
const GLenum RGB5_A1 = 0x8057;
const GLenum RGBA8 = 0x8058;
const GLenum RGB565 = 0x8D62;
const GLenum DEPTH_COMPONENT16 = 0x81A5;
const GLenum STENCIL_INDEX8 = 0x8D48;
Expand Down Expand Up @@ -1728,6 +1777,8 @@ <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>
sequence&lt;DOMString&gt;? getSupportedExtensions();
object? getExtension(DOMString name);

undefined backbufferStorage(GLenum sizedFormat, unsigned long width, unsigned long height);

void activeTexture(GLenum texture);
void attachShader(WebGLProgram program, WebGLShader shader);
void bindAttribLocation(WebGLProgram program, GLuint index, DOMString name);
Expand Down
7 changes: 5 additions & 2 deletions specs/latest/1.0/webgl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// WebGL IDL definitions scraped from the Khronos specification:
// https://www.khronos.org/registry/webgl/specs/latest/

// Copyright (c) 2019 The Khronos Group Inc.
// Copyright (c) 2021 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and/or associated documentation files (the
Expand Down Expand Up @@ -488,6 +488,7 @@ interface mixin WebGLRenderingContextBase

const GLenum RGBA4 = 0x8056;
const GLenum RGB5_A1 = 0x8057;
const GLenum RGBA8 = 0x8058;
const GLenum RGB565 = 0x8D62;
const GLenum DEPTH_COMPONENT16 = 0x81A5;
const GLenum STENCIL_INDEX8 = 0x8D48;
Expand Down Expand Up @@ -545,6 +546,8 @@ interface mixin WebGLRenderingContextBase
sequence<DOMString>? getSupportedExtensions();
object? getExtension(DOMString name);

undefined backbufferStorage(GLenum sizedFormat, unsigned long width, unsigned long height);

void activeTexture(GLenum texture);
void attachShader(WebGLProgram program, WebGLShader shader);
void bindAttribLocation(WebGLProgram program, GLuint index, DOMString name);
Expand Down Expand Up @@ -756,7 +759,7 @@ WebGLRenderingContext includes WebGLRenderingContextOverloads;

[Exposed=(Window,Worker),
Constructor(DOMString type,
optional WebGLContextEventInit eventInit)]
optional WebGLContextEventInit eventInit = {})]
interface WebGLContextEvent : Event {
readonly attribute DOMString statusMessage;
};
Expand Down
1 change: 0 additions & 1 deletion specs/latest/2.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>
const GLenum STENCIL = 0x1802;
const GLenum RED = 0x1903;
const GLenum RGB8 = 0x8051;
const GLenum RGBA8 = 0x8058;
const GLenum RGB10_A2 = 0x8059;
const GLenum TEXTURE_BINDING_3D = 0x806A;
const GLenum UNPACK_SKIP_IMAGES = 0x806D;
Expand Down
3 changes: 1 addition & 2 deletions specs/latest/2.0/webgl2.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// WebGL IDL definitions scraped from the Khronos specification:
// https://www.khronos.org/registry/webgl/specs/latest/

// Copyright (c) 2019 The Khronos Group Inc.
// Copyright (c) 2021 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and/or associated documentation files (the
Expand Down Expand Up @@ -64,7 +64,6 @@ interface mixin WebGL2RenderingContextBase
const GLenum STENCIL = 0x1802;
const GLenum RED = 0x1903;
const GLenum RGB8 = 0x8051;
const GLenum RGBA8 = 0x8058;
const GLenum RGB10_A2 = 0x8059;
const GLenum TEXTURE_BINDING_3D = 0x806A;
const GLenum UNPACK_SKIP_IMAGES = 0x806D;
Expand Down

0 comments on commit 8b7b88a

Please sign in to comment.