Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions specs/latest/2.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ <h3>Types</h3>
<pre class="idl">
typedef long long GLint64;
typedef unsigned long long GLuint64;

dictionary WebGLCopyElementImageConfig {
GLfloat sx;
GLfloat sy;
GLfloat swidth;
GLfloat sheight;
GLsizei width;
GLsizei height;
};
</pre>

<!-- ======================================================================================================= -->
Expand Down Expand Up @@ -935,6 +944,9 @@ <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>
optional unsigned long long srcOffset = 0,
optional GLuint srcLengthOverride = 0);

undefined texElementImage2D(GLenum target, GLenum internalformat, (Element or ElementImage) element,
optional WebGLCopyElementImageConfig config = {}); // May throw DOMException

undefined uniform1fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
optional GLuint srcLength = 0);
undefined uniform2fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
Expand Down Expand Up @@ -2210,6 +2222,31 @@ <h4>Texture objects</h4>
<p><em>offset</em> is the byte offset into the WebGLBuffer's data store; generates an <code>INVALID_VALUE</code> error if it's less than 0.</p>
<p>The ETC2 and EAC texture formats defined in OpenGL ES 3.0 are <a href="#NO_ETC2_EAC">not available in WebGL 2.0</a>.
</dd>

<dt class="idl-code">
[throws] undefined texElementImage2D(GLenum target, GLenum internalformat, (Element or ElementImage) element,
Comment thread
cabanier marked this conversation as resolved.
optional WebGLCopyElementImageConfig config = {});
</dt>
<dd>
<p>Renders <code>element</code> to the currently bound <code>WebGLTexture</code>, redefining level 0 of the texture. This function always operates on level 0.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into this again, I think there's no strong reason to specify this special behavior given that implementations will internally call texImage2D anyway. Passing the input level value through is just as simple as hard-coding 0.

Any application concerns about texture mipmap completeness are resolvable using the config params if needed.

<p>The <code>element</code> argument identifies an <a href="https://whatpr.org/html/11588/canvas.html#concept-canvas-element-image-snapshots">element image snapshot</a>, as defined by HTML. The HTML algorithms define how element image snapshots are created, updated, retrieved, and filtered for security- or privacy-sensitive information. If <code>element</code> is an <code>Element</code>, the source rendering is the snapshot from the most recent <code>paint</code> event for the <a href="#context-canvas">canvas</a> of the current context. If <code>element</code> is an <code>ElementImage</code>, the source rendering is that captured snapshot.</p>
<p>If this function is called with an <code>Element</code> that is not a direct child of the <a href="#context-canvas">canvas</a> of the current context in the most recent rendering update, generates an <code>INVALID_OPERATION</code> error.</p>
<p>If <code>target</code> is not <code>TEXTURE_2D</code>, generates an <code>INVALID_ENUM</code> error.</p>
<p>If no <code>WebGLTexture</code> is bound to <code>target</code>, generates an <code>INVALID_OPERATION</code> error.</p>
<p>All pixel unpack state is ignored by this function, including the <code>PIXEL_UNPACK_BUFFER</code> binding and all <code>UNPACK_</code> pixel store parameters.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My view on this is as follows:

  • Unpack alignment is already ignored for TexImageSource uploads so it's natural to ignore it here.
  • Various unpack skip and dimension parameters cannot be reliably used because the rasterized size is not always known. Therefore, ignoring them seems reasonable. This might be further conditioned on the presence of config.width and config.height, though, because in case they are provided, the regular pixel unpack logic applies just fine.
  • Unpack buffer binding is not a part of pixel state and since it generates an error on all other inapplicable commands, that error should be here as well.

<p>If <code>config.sx</code>, <code>config.sy</code>, <code>config.swidth</code>, and <code>config.sheight</code> are all supplied, they define the source rectangle of the element image snapshot to render, in CSS pixels. If none of them are supplied, the source rectangle has <code>sx</code> and <code>sy</code> of 0, <code>swidth</code> equal to the source's natural width, and <code>sheight</code> equal to the source's natural height. If only some of them are supplied, generates an <code>INVALID_VALUE</code> error.</p>
<p>If <code>config.width</code> and <code>config.height</code> are both supplied, they define the generated texture size, in texels. If neither member is supplied, the texture width and height default to the source rectangle size scaled by the inverse of the canvas-grid-to-CSS scaling factor used to produce the element image snapshot. If only one of them is supplied, generates an <code>INVALID_VALUE</code> error.</p>
<p>The <code>internalformat</code> argument must be one of the values in the following table. Each value has an implied source format of <code>RGBA</code> and the listed implied source type:</p>
<table>
<tr><th>Internal Format</th><th>Implied Source Type</th></tr>
<tr><td>RGBA8</td><td>UNSIGNED_BYTE</td></tr>
<tr><td>SRGB8_ALPHA8</td><td>UNSIGNED_BYTE</td></tr>
<tr><td>RGBA16F</td><td>HALF_FLOAT</td></tr>
<tr><td>RGBA32F</td><td>FLOAT</td></tr>
Comment on lines +2244 to +2245

@lexaknyazev lexaknyazev Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec should be very clear about the transfer functions used in each case.

I'd expect that 8-bit values are always sRGB-encoded and the choice between RGBA8 and SRGB8_ALPHA8 is only to allow apps to bypass hardware sRGB decoding during texture sampling if they wish so for some reason.

However, floating-point values are usually not sRGB encoded. If we aren't sure about the latter, maybe floating-point options could be omitted for now.

</table>
<p>If <code>internalformat</code> is not listed in the table above, generates an <code>INVALID_ENUM</code> error.</p>
<p>If any supplied numeric member of <code>config</code> is negative, or if the computed source rectangle width, source rectangle height, texture width, or texture height is not positive, generates an <code>INVALID_VALUE</code> error.</p>
</dd>
</dl>

<!-- ======================================================================================================= -->
Expand Down
13 changes: 12 additions & 1 deletion specs/latest/2.0/webgl2.idl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
typedef long long GLint64;
typedef unsigned long long GLuint64;

dictionary WebGLCopyElementImageConfig {
GLfloat sx;
GLfloat sy;
GLfloat swidth;
GLfloat sheight;
GLsizei width;
GLsizei height;
};


[Exposed=(Window,Worker)]
interface WebGLQuery : WebGLObject {
Expand Down Expand Up @@ -558,6 +567,9 @@ interface mixin WebGL2RenderingContextOverloads
optional unsigned long long srcOffset = 0,
optional GLuint srcLengthOverride = 0);

undefined texElementImage2D(GLenum target, GLenum internalformat, (Element or ElementImage) element,
optional WebGLCopyElementImageConfig config = {}); // May throw DOMException

undefined uniform1fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
optional GLuint srcLength = 0);
undefined uniform2fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
Expand Down Expand Up @@ -601,4 +613,3 @@ interface WebGL2RenderingContext
WebGL2RenderingContext includes WebGLRenderingContextBase;
WebGL2RenderingContext includes WebGL2RenderingContextBase;
WebGL2RenderingContext includes WebGL2RenderingContextOverloads;