-
Notifications
You must be signed in to change notification settings - Fork 699
add first prototype of texElementImage2D #3752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
3e411b1
c16ae72
948dc72
5a802e7
8a4b80c
ab6501e
51f5f85
40c3709
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
|
|
||
| <!-- ======================================================================================================= --> | ||
|
|
@@ -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, | ||
|
|
@@ -2210,6 +2222,35 @@ <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, | ||
|
cabanier marked this conversation as resolved.
Outdated
|
||
| optional WebGLCopyElementImageConfig config = {}); | ||
| </dt> | ||
| <dd> | ||
| <p>Renders <code>element</code> to the currently bound <code>WebGLTexture</code> at level zero.</p> | ||
| <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>If a <code>WebGLBuffer</code> is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p> | ||
| <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> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace "they define the generated texture size" with "they specify the area of the texture to be modified; this will result in scaling of the source graphic if the specified size does not match the source element's intrinsic size." |
||
| <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
+2247
to
+2248
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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> | ||
| <p> | ||
| If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met, | ||
|
cabanier marked this conversation as resolved.
Outdated
|
||
| generates an <code>INVALID_OPERATION</code> error. | ||
| </p> | ||
| </dd> | ||
| </dl> | ||
|
|
||
| <!-- ======================================================================================================= --> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| GLsizei height; | ||
| }; | ||
|
|
||
|
|
||
| [Exposed=(Window,Worker)] | ||
| interface WebGLQuery : WebGLObject { | ||
|
|
@@ -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, | ||
|
|
@@ -601,4 +613,3 @@ interface WebGL2RenderingContext | |
| WebGL2RenderingContext includes WebGLRenderingContextBase; | ||
| WebGL2RenderingContext includes WebGL2RenderingContextBase; | ||
| WebGL2RenderingContext includes WebGL2RenderingContextOverloads; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
GLint xoffsetandGLint yoffsetparameters aftersheight.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current Element API is
The
texSubImage2DAPI isGiven that the proposed
xoffsetandyoffsetparameters refer to the GL API, why add them to theconfigobject (that is Element-specific) instead of the command (that is GL-specific)? I'd expect them to be in the same group as theleveland the WebGL WG decided thatlevelshould be among the command parameters, not theconfigobject.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also since the new design no longer allocates a GL texture, the
internalformatparameter needs to be moved to theconfig.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words:
config;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation for moving parameters to
WebGLCopyElementImageConfigwas just to avoid the need for overloads of the method just to accommodate various permutations of geometry arguments. The existingWebGLCopyElementImageConfig.(width|height)parameters already specify a destination size, and any scaling they imply is performed by GL, not by web content rendering. So I don't think addingxoffsetandyoffsethere contradicts any existing design principle or separation of web-specific from GL-specific arguments. The purpose ofWebGLCopyElementImageConfigis really to encapsulate all the geometry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite if the command follows the
texSubImagedesign.There are several widths and heights here that exist in separate domains:
texStorageortexImagecommands) and not related to the Element API in any way.xoffsetandyoffset). These have nothing to do with the rasterization geometry and only exist within the texture dimensions set in 1.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have in mind two reasons to prefer adding
xoffsetandyoffsetto the config and leavinginternalFormatwhere it is:It places all geometry parameters in config, which I think is good ergonomics.
It doesn't break existing calling conventions if we allow
xoffsetandyoffsetto default to zero when not specified.In my mind, that's more compelling than keeping the GL-specific bits outside the config. The very fact that this function uses a dictionary of parameters already sets it apart from existing WebGL API's.
Maybe we should get this on the WebGL working group agenda and discuss it there, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. I'll hold off on making changes until it's been discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lexaknyazev -- thinking more about this, I see your point about aligning with the function signature of
texSubImage2Dand keeping the GL-specific parameters separate. Until you pointed it out, I didn't actually know that the automatic scaling behavior of thewidthandheightparameters was specific to the WebGL layer.I'm OK with putting
xoffsetandyoffsetin the main method signature rather than in theconfig. I also think that we can probably get rid of theinternalFormatparameter. So the new IDL would be:Does this look good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lexaknyazev -- I think we're going to proceed with this change to the API, but I'm hoping we can get you to weigh in first; thanks.